GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usr.bin/gprof/printlist.c Lines: 0 12 0.0 %
Date: 2017-11-07 Branches: 0 10 0.0 %

Line Branch Exec Source
1
/*	$OpenBSD: printlist.c,v 1.8 2015/08/20 22:32:41 deraadt Exp $	*/
2
/*	$NetBSD: printlist.c,v 1.5 1995/04/19 07:16:23 cgd Exp $	*/
3
4
/*
5
 * Copyright (c) 1983, 1993
6
 *	The Regents of the University of California.  All rights reserved.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice, this list of conditions and the following disclaimer.
13
 * 2. Redistributions in binary form must reproduce the above copyright
14
 *    notice, this list of conditions and the following disclaimer in the
15
 *    documentation and/or other materials provided with the distribution.
16
 * 3. Neither the name of the University nor the names of its contributors
17
 *    may be used to endorse or promote products derived from this software
18
 *    without specific prior written permission.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30
 * SUCH DAMAGE.
31
 */
32
33
#include <string.h>
34
35
#include "gprof.h"
36
37
    /*
38
     *	these are the lists of names:
39
     *	there is the list head and then the listname
40
     *	is a pointer to the list head
41
     *	(for ease of passing to stringlist functions).
42
     */
43
struct stringlist	kfromhead = { 0 , 0 };
44
struct stringlist	*kfromlist = &kfromhead;
45
struct stringlist	ktohead = { 0 , 0 };
46
struct stringlist	*ktolist = &ktohead;
47
struct stringlist	fhead = { 0 , 0 };
48
struct stringlist	*flist = &fhead;
49
struct stringlist	Fhead = { 0 , 0 };
50
struct stringlist	*Flist = &Fhead;
51
struct stringlist	ehead = { 0 , 0 };
52
struct stringlist	*elist = &ehead;
53
struct stringlist	Ehead = { 0 , 0 };
54
struct stringlist	*Elist = &Ehead;
55
56
void
57
addlist(struct stringlist *listp, char *funcname)
58
{
59
    struct stringlist	*slp;
60
61
    slp = malloc(sizeof(struct stringlist));
62
    if (slp == (struct stringlist *) 0)
63
	errx(0, "ran out room for printlist");
64
    slp -> next = listp -> next;
65
    slp -> string = funcname;
66
    listp -> next = slp;
67
}
68
69
bool
70
onlist(struct stringlist *listp, const char *funcname)
71
{
72
    struct stringlist	*slp;
73
74
    for ( slp = listp -> next ; slp ; slp = slp -> next ) {
75
	if ( ! strcmp( slp -> string , funcname ) ) {
76
	    return TRUE;
77
	}
78
	if ( funcname[0] == '_' && ! strcmp( slp -> string , &funcname[1] ) ) {
79
	    return TRUE;
80
	}
81
    }
82
    return FALSE;
83
}