pool: use GIT_ASSERT
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 54 55 56 57 58 59
diff --git a/src/pool.c b/src/pool.c
index 0c423dd..16ffa39 100644
--- a/src/pool.c
+++ b/src/pool.c
@@ -36,8 +36,8 @@ int git_pool_global_init(void)
int git_pool_init(git_pool *pool, size_t item_size)
{
- assert(pool);
- assert(item_size >= 1);
+ GIT_ASSERT_ARG(pool);
+ GIT_ASSERT_ARG(item_size >= 1);
memset(pool, 0, sizeof(git_pool));
pool->item_size = item_size;
@@ -131,8 +131,8 @@ static int git_pool__ptr_cmp(const void * a, const void * b)
int git_pool_init(git_pool *pool, size_t item_size)
{
- assert(pool);
- assert(item_size >= 1);
+ GIT_ASSERT_ARG(pool);
+ GIT_ASSERT_ARG(item_size >= 1);
memset(pool, 0, sizeof(git_pool));
pool->item_size = item_size;
@@ -205,7 +205,9 @@ char *git_pool_strndup(git_pool *pool, const char *str, size_t n)
{
char *ptr = NULL;
- assert(pool && str && pool->item_size == sizeof(char));
+ GIT_ASSERT_ARG_WITH_RETVAL(pool, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(str, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(pool->item_size == sizeof(char), NULL);
if (n == SIZE_MAX)
return NULL;
@@ -220,7 +222,10 @@ char *git_pool_strndup(git_pool *pool, const char *str, size_t n)
char *git_pool_strdup(git_pool *pool, const char *str)
{
- assert(pool && str && pool->item_size == sizeof(char));
+ GIT_ASSERT_ARG_WITH_RETVAL(pool, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(str, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(pool->item_size == sizeof(char), NULL);
+
return git_pool_strndup(pool, str, strlen(str));
}
@@ -234,7 +239,8 @@ char *git_pool_strcat(git_pool *pool, const char *a, const char *b)
void *ptr;
size_t len_a, len_b, total;
- assert(pool && pool->item_size == sizeof(char));
+ GIT_ASSERT_ARG_WITH_RETVAL(pool, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(pool->item_size == sizeof(char), NULL);
len_a = a ? strlen(a) : 0;
len_b = b ? strlen(b) : 0;