2000-05-29 Philip Blundell <philb@gnu.org>
[binutils.git] / gprof / search_list.c
blobca2928935c07370f923d6935553af74ff015cfc4
1 #include "libiberty.h"
2 #include "gprof.h"
3 #include "search_list.h"
6 void
7 DEFUN (search_list_append, (list, paths),
8 Search_List * list AND const char *paths)
10 Search_List_Elem *new_el;
11 const char *beg, *colon;
12 int len;
14 colon = paths - 1;
17 beg = colon + 1;
18 colon = strchr (beg, PATH_SEP_CHAR);
19 if (colon)
21 len = colon - beg;
23 else
25 len = strlen (beg);
27 new_el = (Search_List_Elem *) xmalloc (sizeof (*new_el) + len);
28 memcpy (new_el->path, beg, len);
29 new_el->path[len] = '\0';
31 /* append new path at end of list: */
32 new_el->next = 0;
33 if (list->tail)
35 list->tail->next = new_el;
37 else
39 list->head = new_el;
41 list->tail = new_el;
43 while (colon);