Back to index

cell-binutils  2.17cvs20070401
search_list.c
Go to the documentation of this file.
00001 /* search-list.c
00002 
00003    Copyright 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
00004 
00005    This file is part of GNU Binutils.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 2 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program; if not, write to the Free Software
00019    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
00020    02110-1301, USA.  */
00021 
00022 #include "libiberty.h"
00023 #include "gprof.h"
00024 #include "search_list.h"
00025 
00026 
00027 void
00028 search_list_append (Search_List *list, const char *paths)
00029 {
00030   Search_List_Elem *new_el;
00031   const char *beg, *colon;
00032   unsigned int len;
00033 
00034   colon = paths - 1;
00035   do
00036     {
00037       beg = colon + 1;
00038       colon = strchr (beg, PATH_SEP_CHAR);
00039 
00040       if (colon)
00041        len = colon - beg;
00042       else
00043        len = strlen (beg);
00044 
00045       new_el = (Search_List_Elem *) xmalloc (sizeof (*new_el) + len);
00046       memcpy (new_el->path, beg, len);
00047       new_el->path[len] = '\0';
00048 
00049       /* Append new path at end of list.  */
00050       new_el->next = 0;
00051 
00052       if (list->tail)
00053        list->tail->next = new_el;
00054       else
00055        list->head = new_el;
00056 
00057       list->tail = new_el;
00058     }
00059   while (colon);
00060 }