diff --git a/common/list.c b/common/list.c index 96b96eb7..9b338eca 100644 --- a/common/list.c +++ b/common/list.c @@ -179,3 +179,21 @@ list_insert_item(struct list* self, int index, long item) self->items[index] = item; } } + +/*****************************************************************************/ +/* append one list to another using strdup for each item in the list */ +/* begins copy at start_index, a zero based index on the soure list */ +void APP_CC +list_append_list_strdup(struct list* self, struct list* dest, int start_index) +{ + int index; + long item; + char* dup; + + for (index = start_index; index < self->count; index++) + { + item = list_get_item(self, index); + dup = g_strdup((char*)item); + list_add_item(dest, (long)dup); + } +} diff --git a/common/list.h b/common/list.h index a1163515..fa66f643 100644 --- a/common/list.h +++ b/common/list.h @@ -47,5 +47,7 @@ void APP_CC list_remove_item(struct list* self, int index); void APP_CC list_insert_item(struct list* self, int index, long item); +void APP_CC +list_append_list_strdup(struct list* self, struct list* dest, int start_index); #endif