X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_acl%2Ftb_mem.c;h=157e60801530033c4760b8313c817a421ace5304;hb=afd7f2d86a7e9bfa286224d12e558330b0ef4ed2;hp=fdf3080b435e3db5d98917b77e5f92e4ffa32a1a;hpb=c660072c30d2e3b92935c358451c6179db0f6f08;p=dpdk.git diff --git a/lib/librte_acl/tb_mem.c b/lib/librte_acl/tb_mem.c index fdf3080b43..157e608015 100644 --- a/lib/librte_acl/tb_mem.c +++ b/lib/librte_acl/tb_mem.c @@ -37,6 +37,11 @@ * Memory management routines for temporary memory. * That memory is used only during build phase and is released after * build is finished. + * Note, that tb_pool/tb_alloc() are not supposed to return NULL. + * Instead, in the case of failure to allocate memory, + * it would do siglongjmp(pool->fail). + * It is responsibility of the caller to save the proper context/environment, + * in the pool->fail before calling tb_alloc() for the given pool first time. */ static struct tb_mem_block * @@ -51,6 +56,7 @@ tb_pool(struct tb_mem_pool *pool, size_t sz) if (block == NULL) { RTE_LOG(ERR, MALLOC, "%s(%zu)\n failed, currently allocated " "by pool: %zu bytes\n", __func__, sz, pool->alloc); + siglongjmp(pool->fail, -ENOMEM); return NULL; } @@ -81,8 +87,6 @@ tb_alloc(struct tb_mem_pool *pool, size_t size) if (block == NULL || block->size < size) { new_sz = (size > pool->min_alloc) ? size : pool->min_alloc; block = tb_pool(pool, new_sz); - if (block == NULL) - return NULL; } ptr = block->mem; block->size -= size;