1
2
3
4
5
6
7
8
9
10 #ifndef _DICT_PRIVATE_H_
11 #define _DICT_PRIVATE_H_
12
13 #include "dict.h"
14
15 typedef int (*insert_func) __P((void *, void *k, void *d, int o));
16 typedef int (*probe_func) __P((void *, void *k, void **d));
17 typedef void *(*search_func) __P((void *, const void *k));
18 typedef int (*remove_func) __P((void *, const void *k, int d));
19 typedef void (*walk_func) __P((void *, dict_vis_func visit));
20 typedef unsigned (*count_func) __P((const void *));
21 typedef void (*empty_func) __P((void *, int del));
22 typedef void (*destroy_func) __P((void *, int del));
23 typedef dict_itor *(*inew_func) __P((void *));
24
25 typedef void (*idestroy_func) __P((void *));
26 typedef int (*valid_func) __P((const void *));
27 typedef void (*invalidate_func) __P((void *));
28 typedef int (*next_func) __P((void *));
29 typedef int (*prev_func) __P((void *));
30 typedef int (*nextn_func) __P((void *, unsigned count));
31 typedef int (*prevn_func) __P((void *, unsigned count));
32 typedef int (*first_func) __P((void *));
33 typedef int (*last_func) __P((void *));
34 typedef int (*isearch_func) __P((void *, const void *k));
35 typedef const void *(*key_func) __P((void *));
36 typedef void *(*data_func) __P((void *));
37 typedef const void *(*cdata_func) __P((const void *));
38 typedef int (*dataset_func) __P((void *, void *d, int del));
39 typedef int (*iremove_func) __P((void *, int del));
40 typedef int (*icompare_func) __P((void *, void *itor2));
41
42 #ifndef NDEBUG
43 # include <stdio.h>
44 # undef ASSERT
45 # if defined(__GNUC__)
46 # define ASSERT(expr) \
47 if (!(expr)) \
48 fprintf(stderr, "\n%s:%d (%s) assertion failed: `%s'\n", \
49 __FILE__, __LINE__, __func__, #expr), \
50 abort()
51 # else
52 # define ASSERT(expr) \
53 if (!(expr)) \
54 fprintf(stderr, "\n%s:%d assertion failed: `%s'\n", \
55 __FILE__, __LINE__, #expr), \
56 abort()
57 # endif
58 #else
59 # define ASSERT(expr)
60 #endif
61
62 extern dict_malloc_func _dict_malloc;
63 extern dict_free_func _dict_free;
64 #define MALLOC(n) (*_dict_malloc)(n)
65 #define FREE(p) (*_dict_free)(p)
66
67 #define ABS(a) ((a) < 0 ? -(a) : +(a))
68 #define MIN(a,b) ((a) < (b) ? (a) : (b))
69 #define MAX(a,b) ((a) > (b) ? (a) : (b))
70 #define SWAP(a,b,v) v = (a), (a) = (b), (b) = v
71 #define UNUSED(p) (void)&p
72
73 #if defined(__GNUC__)
74 # define GCC_INLINE inline
75 # define GCC_UNUSED __attribute__((__unused__))
76 # define GCC_CONST __attribute__((__const__))
77 #else
78 # define GCC_INLINE
79 # define GCC_UNUSED
80 # define GCC_CONST
81 #endif
82
83 #endif