NVBIO
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Macros
klist.h File Reference
#include <stdlib.h>

Go to the source code of this file.

Macros

#define KMEMPOOL_INIT(name, kmptype_t, kmpfree_f)
 
#define kmempool_t(name)   kmp_##name##_t
 
#define kmp_init(name)   kmp_init_##name()
 
#define kmp_destroy(name, mp)   kmp_destroy_##name(mp)
 
#define kmp_alloc(name, mp)   kmp_alloc_##name(mp)
 
#define kmp_free(name, mp, p)   kmp_free_##name(mp, p)
 
#define KLIST_INIT(name, kltype_t, kmpfree_t)
 
#define kliter_t(name)   kl1_##name
 
#define klist_t(name)   kl_##name##_t
 
#define kl_val(iter)   ((iter)->data)
 
#define kl_next(iter)   ((iter)->next)
 
#define kl_begin(kl)   ((kl)->head)
 
#define kl_end(kl)   ((kl)->tail)
 
#define kl_init(name)   kl_init_##name()
 
#define kl_destroy(name, kl)   kl_destroy_##name(kl)
 
#define kl_pushp(name, kl)   kl_pushp_##name(kl)
 
#define kl_shift(name, kl, d)   kl_shift_##name(kl, d)
 

Macro Definition Documentation

#define kl_begin (   kl)    ((kl)->head)

Definition at line 113 of file klist.h.

#define kl_destroy (   name,
  kl 
)    kl_destroy_##name(kl)

Definition at line 117 of file klist.h.

#define kl_end (   kl)    ((kl)->tail)

Definition at line 114 of file klist.h.

#define kl_init (   name)    kl_init_##name()

Definition at line 116 of file klist.h.

#define kl_next (   iter)    ((iter)->next)

Definition at line 112 of file klist.h.

#define kl_pushp (   name,
  kl 
)    kl_pushp_##name(kl)

Definition at line 118 of file klist.h.

#define kl_shift (   name,
  kl,
 
)    kl_shift_##name(kl, d)

Definition at line 119 of file klist.h.

#define kl_val (   iter)    ((iter)->data)

Definition at line 111 of file klist.h.

#define KLIST_INIT (   name,
  kltype_t,
  kmpfree_t 
)

Definition at line 66 of file klist.h.

#define klist_t (   name)    kl_##name##_t

Definition at line 110 of file klist.h.

#define kliter_t (   name)    kl1_##name

Definition at line 109 of file klist.h.

#define KMEMPOOL_INIT (   name,
  kmptype_t,
  kmpfree_f 
)
Value:
typedef struct { \
size_t cnt, n, max; \
kmptype_t **buf; \
} kmp_##name##_t; \
static inline kmp_##name##_t *kmp_init_##name(void) { \
return calloc(1, sizeof(kmp_##name##_t)); \
} \
static inline void kmp_destroy_##name(kmp_##name##_t *mp) { \
size_t k; \
for (k = 0; k < mp->n; ++k) { \
kmpfree_f(mp->buf[k]); free(mp->buf[k]); \
} \
free(mp->buf); free(mp); \
} \
static inline kmptype_t *kmp_alloc_##name(kmp_##name##_t *mp) { \
++mp->cnt; \
if (mp->n == 0) return calloc(1, sizeof(kmptype_t)); \
return mp->buf[--mp->n]; \
} \
static inline void kmp_free_##name(kmp_##name##_t *mp, kmptype_t *p) { \
--mp->cnt; \
if (mp->n == mp->max) { \
mp->max = mp->max? mp->max<<1 : 16; \
mp->buf = realloc(mp->buf, sizeof(kmptype_t *) * mp->max); \
} \
mp->buf[mp->n++] = p; \
}

Definition at line 31 of file klist.h.

#define kmempool_t (   name)    kmp_##name##_t

Definition at line 60 of file klist.h.

#define kmp_alloc (   name,
  mp 
)    kmp_alloc_##name(mp)

Definition at line 63 of file klist.h.

#define kmp_destroy (   name,
  mp 
)    kmp_destroy_##name(mp)

Definition at line 62 of file klist.h.

#define kmp_free (   name,
  mp,
 
)    kmp_free_##name(mp, p)

Definition at line 64 of file klist.h.

#define kmp_init (   name)    kmp_init_##name()

Definition at line 61 of file klist.h.