link-grammar-5.8.0/link-grammar/memory-pool.c
/*
 * Allocate an element by using malloc() directly.
 */
Allocate an element by using malloc() directly.
Allocate an element by using malloc () directly .
void *pool_alloc(Pool_desc *mp)
{
	mp->curr_elements++;
#ifdef POOL_EXACT
	assert(!mp->exact || mp->curr_elements <= mp->num_elements,
	       "Too many elements (%zu>%zu) (pool '%s' created in %s())",
	       mp->curr_elements, mp->num_elements, mp->name, mp->func);
#endif 
	char *next = mp->chain;
	mp->chain = malloc(mp->element_size + FLDSIZE_NEXT);
	POOL_NEXT_BLOCK(mp->chain, mp->element_size) = next;
	void *alloc_next = mp->chain;
	if (mp->zero_out) memset(alloc_next, 0, mp->element_size);
	return alloc_next;
}
void * pool_alloc ( Pool_desc * mp ) { mp -> curr_elements ++ ; #ifdef POOL_EXACT assert ( ! mp -> exact || mp -> curr_elements <= mp -> num_elements , " " , mp -> curr_elements , mp -> num_elements , mp -> name , mp -> func ) ; #endif char * next = mp -> chain ; mp -> chain = malloc ( mp -> element_size + FLDSIZE_NEXT ) ; POOL_NEXT_BLOCK ( mp -> chain , mp -> element_size ) = next ; void * alloc_next = mp -> chain ; if ( mp -> zero_out ) memset ( alloc_next , 0 , mp -> element_size ) ; return alloc_next ; }
Allocate an element by using malloc() directly.
Allocate an element by using malloc () directly .
/* POOL_EXACT */ /* Allocate a new element and chain it. */