comparison lwlib/lw_stringlist.c @ 327:80826bf2827b

Added copier for stringlist module
author lost
date Sat, 13 Feb 2010 06:08:04 +0000
parents 2eb058346cad
children 33c5bc04ea67
comparison
equal deleted inserted replaced
326:2eb058346cad 327:80826bf2827b
73 73
74 int lw_stringlist_nstrings(lw_stringlist_t S) 74 int lw_stringlist_nstrings(lw_stringlist_t S)
75 { 75 {
76 return S -> nstrings; 76 return S -> nstrings;
77 } 77 }
78
79 lw_stringlist_t lw_stringlist_copy(lw_stringlist_t S)
80 {
81 lw_stringlist_t r;
82
83 r = lw_alloc(sizeof(lw_stringlist_t));
84 r -> nstrings = S -> nstrings;
85 if (S -> nstrings)
86 {
87 int i;
88
89 r -> strings = lw_alloc(sizeof(char *) * S -> nstrings);
90 for (i = 0; i < S -> nstrings; i++)
91 {
92 r -> strings[i] = lw_strdup(S -> strings[i]);
93 }
94 }
95 return r;
96 }