Commit | Line | Data |
---|---|---|
5489fcc3 KR |
1 | #include "libiberty.h" |
2 | #include "gprof.h" | |
3 | #include "search_list.h" | |
4 | ||
5 | ||
6 | void | |
7 | DEFUN(search_list_append, (list, paths), | |
8 | Search_List *list AND const char *paths) | |
9 | { | |
10 | Search_List_Elem *new_el; | |
11 | const char *beg, *colon; | |
12 | int len; | |
13 | ||
14 | colon = paths - 1; | |
15 | do { | |
16 | beg = colon + 1; | |
17 | colon = strchr(beg, ':'); | |
18 | if (colon) { | |
19 | len = colon - beg; | |
20 | } else { | |
21 | len = strlen(beg); | |
22 | } /* if */ | |
23 | new_el = (Search_List_Elem*) xmalloc(sizeof(*new_el) + len); | |
24 | memcpy(new_el->path, beg, len); | |
25 | new_el->path[len] = '\0'; | |
26 | ||
27 | /* append new path at end of list: */ | |
28 | new_el->next = 0; | |
29 | if (list->tail) { | |
30 | list->tail->next = new_el; | |
31 | } else { | |
32 | list->head = new_el; | |
33 | } /* if */ | |
34 | list->tail = new_el; | |
35 | } while (colon); | |
36 | } /* search_list_append */ | |
37 | ||
38 | /*** end of search_list.c ***/ |