File: test-ohash.c

package info (click to toggle)
mdocml 1.14.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 9,096 kB
  • sloc: ansic: 34,421; makefile: 994; sh: 461; perl: 374
file content (39 lines) | stat: -rw-r--r-- 585 bytes parent folder | download
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
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <ohash.h>

static void	*xmalloc(size_t, void *);
static void	*xcalloc(size_t, size_t, void *);
static void	 xfree(void *, void *);


static void *
xmalloc(size_t sz, void *arg) {
	return calloc(1,sz);
}

static void *
xcalloc(size_t nmemb, size_t sz, void *arg)
{
	return calloc(nmemb,sz);
}

static void
xfree(void *p, void *arg)
{
	free(p);
}

int
main(void)
{
	struct ohash h;
	struct ohash_info i;
	i.alloc = xmalloc;
	i.calloc = xcalloc;
	i.free = xfree;
	ohash_init(&h, 2, &i);
	ohash_delete(&h);
	return 0;
}