| 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 | { |
| 17 | beg = colon + 1; |
| 18 | colon = strchr (beg, ':'); |
| 19 | if (colon) |
| 20 | { |
| 21 | len = colon - beg; |
| 22 | } |
| 23 | else |
| 24 | { |
| 25 | len = strlen (beg); |
| 26 | } |
| 27 | new_el = (Search_List_Elem *) xmalloc (sizeof (*new_el) + len); |
| 28 | memcpy (new_el->path, beg, len); |
| 29 | new_el->path[len] = '\0'; |
| 30 | |
| 31 | /* append new path at end of list: */ |
| 32 | new_el->next = 0; |
| 33 | if (list->tail) |
| 34 | { |
| 35 | list->tail->next = new_el; |
| 36 | } |
| 37 | else |
| 38 | { |
| 39 | list->head = new_el; |
| 40 | } |
| 41 | list->tail = new_el; |
| 42 | } |
| 43 | while (colon); |
| 44 | } |