xref: /csrg-svn/usr.bin/gprof/printlist.c (revision 30963)
1 /*
2  * Copyright (c) 1983 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  */
6 
7 #ifndef lint
8 static char sccsid[] = "@(#)printlist.c	5.2 (Berkeley) 04/27/87";
9 #endif not lint
10 
11 #include "gprof.h"
12 
13     /*
14      *	these are the lists of names:
15      *	there is the list head and then the listname
16      *	is a pointer to the list head
17      *	(for ease of passing to stringlist functions).
18      */
19 struct stringlist	kfromhead = { 0 , 0 };
20 struct stringlist	*kfromlist = &kfromhead;
21 struct stringlist	ktohead = { 0 , 0 };
22 struct stringlist	*ktolist = &ktohead;
23 struct stringlist	fhead = { 0 , 0 };
24 struct stringlist	*flist = &fhead;
25 struct stringlist	Fhead = { 0 , 0 };
26 struct stringlist	*Flist = &Fhead;
27 struct stringlist	ehead = { 0 , 0 };
28 struct stringlist	*elist = &ehead;
29 struct stringlist	Ehead = { 0 , 0 };
30 struct stringlist	*Elist = &Ehead;
31 
32 addlist( listp , funcname )
33     struct stringlist	*listp;
34     char		*funcname;
35 {
36     struct stringlist	*slp;
37 
38     slp = (struct stringlist *) malloc( sizeof(struct stringlist));
39     if ( slp == (struct stringlist *) 0 ) {
40 	fprintf( stderr, "gprof: ran out room for printlist\n" );
41 	done();
42     }
43     slp -> next = listp -> next;
44     slp -> string = funcname;
45     listp -> next = slp;
46 }
47 
48 bool
49 onlist( listp , funcname )
50     struct stringlist	*listp;
51     char		*funcname;
52 {
53     struct stringlist	*slp;
54 
55     for ( slp = listp -> next ; slp ; slp = slp -> next ) {
56 	if ( ! strcmp( slp -> string , funcname ) ) {
57 	    return TRUE;
58 	}
59 	if ( funcname[0] == '_' && ! strcmp( slp -> string , &funcname[1] ) ) {
60 	    return TRUE;
61 	}
62     }
63     return FALSE;
64 }
65