it is handy to be able to see allocated bitfields in the show
memory output.
Signed-off-by: Pat Ruddy <pat@voltanet.io>
*/
typedef struct {word_t *data; size_t n, m; } bitfield_t;
+DECLARE_MTYPE(BITFIELD);
+
/**
* Initialize the bits.
* @v: an instance of bitfield_t struct.
do { \
(v).n = 0; \
(v).m = ((N) / WORD_SIZE + 1); \
- (v).data = calloc(1, ((v).m * sizeof(word_t))); \
+ (v).data = XCALLOC(MTYPE_BITFIELD, ((v).m * sizeof(word_t))); \
} while (0)
/**
*/
#define bf_free(v) \
do { \
- free((v).data); \
+ XFREE(MTYPE_BITFIELD, (v).data); \
(v).data = NULL; \
} while (0)
DEFINE_MGROUP(LIB, "libfrr");
DEFINE_MTYPE(LIB, TMP, "Temporary memory");
+DEFINE_MTYPE(LIB, BITFIELD, "Bitfield memory");
static inline void mt_count_alloc(struct memtype *mt, size_t size, void *ptr)
{