Commit abfdb8a6d252a4834df9234ad338c97f1a4f97f2

Edward Thomson 2020-05-23T10:15:37

git_pool_init: return an int Let `git_pool_init` return an int so that it could fail.

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