struct VdlList * vdl_utils_strsplit (const char *value, char separator) { VDL_LOG_FUNCTION ("value=%s, separator=%d", (value == 0) ? "" : value, separator); struct VdlList *list = vdl_list_new (); const char *prev = value; const char *cur = value; if (value == 0) { return list; } while (1) { size_t prev_len; char *str; while (*cur != separator && *cur != 0) { cur++; } prev_len = cur - prev; str = vdl_alloc_malloc (prev_len + 1); vdl_memcpy (str, prev, prev_len); str[prev_len] = 0; vdl_list_push_back (list, str); if (*cur == 0) { break; } cur++; prev = cur; } return list; }
struct VdlList *vdl_list_copy (struct VdlList *list) { struct VdlList *copy = vdl_list_new (); vdl_list_insert_range (copy, vdl_list_begin (copy), vdl_list_begin (list), vdl_list_end (list)); return copy; }