Subject: Re: [PATCH 4/7] Add a memory pool library

From: Jonathan Nieder <[email-masked]>
Date: Sat, 29 May 2010 04:06:10 -0500

Ramkumar Ramachandra wrote:

> Add a memory pool library implemented using cpp macros.

Hmm, like talloc[1].  How do they compare?

[...]
> + *   pre              : Prefix for generated functions (ex: string_).
> + *   obj_t            : Type for treap data structure (ex: char).
> + *   intial_capacity  : The initial size of the memory pool (ex: 4096).
> + *
> + */
> +#define obj_pool_gen(pre, obj_t, initial_capacity)                         \
> +static struct {                                                            \
> +    uint32_t size;                                                         \
> +    uint32_t capacity;                                                     \
> +    obj_t *base;                                                           \
> +} pre##_pool = { 0, 0, NULL};                                              \
> +static uint32_t pre##_alloc(uint32_t count)                                \
[...]

This makes functions with names like string_alloc(), which would then
be un-greppable.  It might be nice (though certainly not necessary) to
provide an overview in Documentation/technical/ so there is no need to
find the definition of each function.

Jonathan

[1] http://ccan.ozlabs.org/info/talloc.html