From: Jonathan Nieder Date: Sat, 29 May 2010 09:06:10 GMT Subject: Re: [PATCH 4/7] Add a memory pool library Message-ID: <20100529090609.GA7247@progeny.tock> In-Reply-To: <1274650832-7411-5-git-send-email-artagnon@gmail.com> 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