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 this notice is preserved and that due credit is given 7 * to the University of California at Berkeley. The name of the University 8 * may not be used to endorse or promote products derived from this 9 * software without specific prior written permission. This software 10 * is provided ``as is'' without express or implied warranty. 11 */ 12 13 #ifndef lint 14 static char sccsid[] = "@(#)printlist.c 5.3 (Berkeley) 05/05/88"; 15 #endif /* not lint */ 16 17 #include "gprof.h" 18 19 /* 20 * these are the lists of names: 21 * there is the list head and then the listname 22 * is a pointer to the list head 23 * (for ease of passing to stringlist functions). 24 */ 25 struct stringlist kfromhead = { 0 , 0 }; 26 struct stringlist *kfromlist = &kfromhead; 27 struct stringlist ktohead = { 0 , 0 }; 28 struct stringlist *ktolist = &ktohead; 29 struct stringlist fhead = { 0 , 0 }; 30 struct stringlist *flist = &fhead; 31 struct stringlist Fhead = { 0 , 0 }; 32 struct stringlist *Flist = &Fhead; 33 struct stringlist ehead = { 0 , 0 }; 34 struct stringlist *elist = &ehead; 35 struct stringlist Ehead = { 0 , 0 }; 36 struct stringlist *Elist = &Ehead; 37 38 addlist( listp , funcname ) 39 struct stringlist *listp; 40 char *funcname; 41 { 42 struct stringlist *slp; 43 44 slp = (struct stringlist *) malloc( sizeof(struct stringlist)); 45 if ( slp == (struct stringlist *) 0 ) { 46 fprintf( stderr, "gprof: ran out room for printlist\n" ); 47 done(); 48 } 49 slp -> next = listp -> next; 50 slp -> string = funcname; 51 listp -> next = slp; 52 } 53 54 bool 55 onlist( listp , funcname ) 56 struct stringlist *listp; 57 char *funcname; 58 { 59 struct stringlist *slp; 60 61 for ( slp = listp -> next ; slp ; slp = slp -> next ) { 62 if ( ! strcmp( slp -> string , funcname ) ) { 63 return TRUE; 64 } 65 if ( funcname[0] == '_' && ! strcmp( slp -> string , &funcname[1] ) ) { 66 return TRUE; 67 } 68 } 69 return FALSE; 70 } 71