summaryrefslogtreecommitdiff
path: root/source/fitz/track-usage.c
blob: f2d8af49a768c8aec55816dffdbcf539c36e64ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "mupdf/fitz.h"

#ifdef TRACK_USAGE

static track_usage_data_t *usage_head = NULL;

static void dump_usage(void)
{
	track_usage_data_t *u = usage_head;

	while (u)
	{
		fprintf(stderr, "USAGE: %s (%s:%d) %d calls\n",
			u->desc, u->function, u->line, u->count);
		u = u->next;
	}
}

void track_usage(track_usage_data_t *data, const char *function, int line, const char *desc)
{
	int c = data->count++;
	if (c == 0)
	{
		data->function = function;
		data->line = line;
		data->desc = desc;
		if (usage_head == NULL)
			atexit(dump_usage);
		data->next = usage_head;
		usage_head = data;
	}
}

#endif