5 #include <string.h> /* memcpy */
16 struct string_list_t
*
19 struct string_list_t
* list
= (struct string_list_t
*)
20 malloc (sizeof (struct string_list_t
) );
21 list
->item
= malloc (BASE_SIZE
* sizeof (int) );
22 list
->size
= BASE_SIZE
;
30 delete_list (struct string_list_t
* list
)
37 get_item (struct string_list_t
* list
, unsigned int item
)
39 return ( item
>= list
->used
) ? -1 : list
->item
[item
];
44 add_item (struct string_list_t
* list
, unsigned int item
)
46 if (list
->used
== list
->size
) {
47 list
->size
+= BASE_SIZE
;
48 list
->item
= realloc (list
->item
, list
->size
* sizeof (int) );
51 list
->item
[list
->used
++] = item
;
58 add_list (struct string_list_t
* dst
, struct string_list_t
* src
)
60 if (dst
->used
+ src
->used
> dst
->size
) {
61 dst
->size
= dst
->used
+ src
->used
;
62 dst
->item
= realloc (dst
->item
, dst
->size
* sizeof (int) );
65 memcpy (&dst
->item
[dst
->used
], src
->item
, src
->used
* sizeof (int) );
66 dst
->used
+= src
->used
;