1 /* 2 * Copyright (c) 1983 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 */ 17 18 #ifndef lint 19 static char sccsid[] = "@(#)printlist.c 5.4 (Berkeley) 06/29/88"; 20 #endif /* not lint */ 21 22 #include "gprof.h" 23 24 /* 25 * these are the lists of names: 26 * there is the list head and then the listname 27 * is a pointer to the list head 28 * (for ease of passing to stringlist functions). 29 */ 30 struct stringlist kfromhead = { 0 , 0 }; 31 struct stringlist *kfromlist = &kfromhead; 32 struct stringlist ktohead = { 0 , 0 }; 33 struct stringlist *ktolist = &ktohead; 34 struct stringlist fhead = { 0 , 0 }; 35 struct stringlist *flist = &fhead; 36 struct stringlist Fhead = { 0 , 0 }; 37 struct stringlist *Flist = &Fhead; 38 struct stringlist ehead = { 0 , 0 }; 39 struct stringlist *elist = &ehead; 40 struct stringlist Ehead = { 0 , 0 }; 41 struct stringlist *Elist = &Ehead; 42 43 addlist( listp , funcname ) 44 struct stringlist *listp; 45 char *funcname; 46 { 47 struct stringlist *slp; 48 49 slp = (struct stringlist *) malloc( sizeof(struct stringlist)); 50 if ( slp == (struct stringlist *) 0 ) { 51 fprintf( stderr, "gprof: ran out room for printlist\n" ); 52 done(); 53 } 54 slp -> next = listp -> next; 55 slp -> string = funcname; 56 listp -> next = slp; 57 } 58 59 bool 60 onlist( listp , funcname ) 61 struct stringlist *listp; 62 char *funcname; 63 { 64 struct stringlist *slp; 65 66 for ( slp = listp -> next ; slp ; slp = slp -> next ) { 67 if ( ! strcmp( slp -> string , funcname ) ) { 68 return TRUE; 69 } 70 if ( funcname[0] == '_' && ! strcmp( slp -> string , &funcname[1] ) ) { 71 return TRUE; 72 } 73 } 74 return FALSE; 75 } 76