aboutsummaryrefslogtreecommitdiffstats
path: root/roms/skiboot/ccan/heap/_info
blob: fe5866d046773c277d76e62dc5bacb5e46d70a46 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "config.h"
#include <stdio.h>
#include <string.h>

/**
 * heap - a simple heap implementation
 *
 * Each heap entry is added as a void pointer. This means the implementation
 * does _not_ assume you already have an array of entries. Instead, it keeps
 * an internal array of pointers to those entries.
 *
 * Example:
 *	#include <stdio.h>
 *
 *	#include <ccan/heap/heap.h>
 *
 *	static bool less(const int *i, const int *j)
 *	{
 *		return *i < *j;
 *	}
 *
 *	static bool __less(const void *i, const void *j)
 *	{
 *		return less(i, j);
 *	}
 *
 *	int main(int argc, char *argv[])
 *	{
 *		struct heap *h;
 *		int arr[] = {1, 0, 2};
 *		int i;
 *
 *		h = heap_init(__less);
 *		if (h == NULL) {
 *			perror("heap alloc");
 *			exit(1);
 *		}
 *
 *		for (i = 0; i < 3; i++) {
 *			if (heap_push(h, &arr[i])) {
 *				perror("heap push");
 *				exit(1);
 *			}
 *		}
 *		// should print 0, 1, 2
 *		for (i = 0; i < 3; i++) {
 *			int *v = heap_pop(h);
 *			printf("%d\n", *v);
 *		}
 *		heap_free(h);
 *		return 0;
 *	}
 *
 * License: BSD-MIT
 * Author: Emilio G. Cota <cota@braap.org>
 */
int main(int argc, char *argv[])
{
	/* Expect exactly one argument */
	if (argc != 2)
		return 1;

	if (strcmp(argv[1], "depends") == 0) {
		return 0;
	}

	return 1;
}