From 4444690400de3c61ef66a1512047637dca4d857d Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 6 Sep 2012 11:24:01 -0700 Subject: [PATCH] Implement guac_pool alloc and free. --- libguac/src/pool.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/libguac/src/pool.c b/libguac/src/pool.c index f95dd51d..d8469ed5 100644 --- a/libguac/src/pool.c +++ b/libguac/src/pool.c @@ -36,18 +36,30 @@ * ***** END LICENSE BLOCK ***** */ #include +#include #include "pool.h" guac_pool* guac_pool_alloc(int size) { - /* STUB */ - return NULL; + guac_pool* pool = malloc(sizeof(guac_pool)); + + /* If unable to allocate, just return NULL. */ + if (pool == NULL) + return NULL; + + /* Initialize empty pool */ + pool->min_size = size; + pool->__next_value = 0; + pool->__head = NULL; + pool->__tail = NULL; + + return pool; } void guac_pool_free(guac_pool* pool) { - /* STUB */ + free(pool); } int guac_pool_next_int(guac_pool* pool) {