git_pool_init: return an int Let `git_pool_init` return an int so that it could fail.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
diff --git a/src/pool.c b/src/pool.c
index b3bc8d4..baae918 100644
--- a/src/pool.c
+++ b/src/pool.c
@@ -37,7 +37,7 @@ size_t git_pool__system_page_size(void)
}
#ifndef GIT_DEBUG_POOL
-void git_pool_init(git_pool *pool, size_t item_size)
+int git_pool_init(git_pool *pool, size_t item_size)
{
assert(pool);
assert(item_size >= 1);
@@ -45,6 +45,8 @@ void git_pool_init(git_pool *pool, size_t item_size)
memset(pool, 0, sizeof(git_pool));
pool->item_size = item_size;
pool->page_size = git_pool__system_page_size();
+
+ return 0;
}
void git_pool_clear(git_pool *pool)
@@ -125,7 +127,7 @@ static int git_pool__ptr_cmp(const void * a, const void * b)
}
}
-void git_pool_init(git_pool *pool, size_t item_size)
+int git_pool_init(git_pool *pool, size_t item_size)
{
assert(pool);
assert(item_size >= 1);
@@ -134,6 +136,8 @@ void git_pool_init(git_pool *pool, size_t item_size)
pool->item_size = item_size;
pool->page_size = git_pool__system_page_size();
git_vector_init(&pool->allocations, 100, git_pool__ptr_cmp);
+
+ return 0;
}
void git_pool_clear(git_pool *pool)
diff --git a/src/pool.h b/src/pool.h
index 23f6899..969d0e7 100644
--- a/src/pool.h
+++ b/src/pool.h
@@ -81,7 +81,7 @@ typedef struct {
* Of course, you can use this in other ways, but those are the
* two most common patterns.
*/
-extern void git_pool_init(git_pool *pool, size_t item_size);
+extern int git_pool_init(git_pool *pool, size_t item_size);
/**
* Free all items in pool