Commit abfdb8a6 by Edward Thomson

git_pool_init: return an int

Let `git_pool_init` return an int so that it could fail.
parent e4bdba56
...@@ -37,7 +37,7 @@ size_t git_pool__system_page_size(void) ...@@ -37,7 +37,7 @@ size_t git_pool__system_page_size(void)
} }
#ifndef GIT_DEBUG_POOL #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(pool);
assert(item_size >= 1); assert(item_size >= 1);
...@@ -45,6 +45,8 @@ void git_pool_init(git_pool *pool, size_t item_size) ...@@ -45,6 +45,8 @@ void git_pool_init(git_pool *pool, size_t item_size)
memset(pool, 0, sizeof(git_pool)); memset(pool, 0, sizeof(git_pool));
pool->item_size = item_size; pool->item_size = item_size;
pool->page_size = git_pool__system_page_size(); pool->page_size = git_pool__system_page_size();
return 0;
} }
void git_pool_clear(git_pool *pool) void git_pool_clear(git_pool *pool)
...@@ -125,7 +127,7 @@ static int git_pool__ptr_cmp(const void * a, const void * b) ...@@ -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(pool);
assert(item_size >= 1); assert(item_size >= 1);
...@@ -134,6 +136,8 @@ void git_pool_init(git_pool *pool, size_t item_size) ...@@ -134,6 +136,8 @@ void git_pool_init(git_pool *pool, size_t item_size)
pool->item_size = item_size; pool->item_size = item_size;
pool->page_size = git_pool__system_page_size(); pool->page_size = git_pool__system_page_size();
git_vector_init(&pool->allocations, 100, git_pool__ptr_cmp); git_vector_init(&pool->allocations, 100, git_pool__ptr_cmp);
return 0;
} }
void git_pool_clear(git_pool *pool) void git_pool_clear(git_pool *pool)
......
...@@ -81,7 +81,7 @@ typedef struct { ...@@ -81,7 +81,7 @@ typedef struct {
* Of course, you can use this in other ways, but those are the * Of course, you can use this in other ways, but those are the
* two most common patterns. * 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 * Free all items in pool
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment