Skip to content

Commit 9502f8e

Browse files
committed
pool: use GIT_ASSERT
1 parent 4b093e7 commit 9502f8e

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/pool.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ int git_pool_global_init(void)
3636

3737
int git_pool_init(git_pool *pool, size_t item_size)
3838
{
39-
assert(pool);
40-
assert(item_size >= 1);
39+
GIT_ASSERT_ARG(pool);
40+
GIT_ASSERT_ARG(item_size >= 1);
4141

4242
memset(pool, 0, sizeof(git_pool));
4343
pool->item_size = item_size;
@@ -131,8 +131,8 @@ static int git_pool__ptr_cmp(const void * a, const void * b)
131131

132132
int git_pool_init(git_pool *pool, size_t item_size)
133133
{
134-
assert(pool);
135-
assert(item_size >= 1);
134+
GIT_ASSERT_ARG(pool);
135+
GIT_ASSERT_ARG(item_size >= 1);
136136

137137
memset(pool, 0, sizeof(git_pool));
138138
pool->item_size = item_size;
@@ -205,7 +205,9 @@ char *git_pool_strndup(git_pool *pool, const char *str, size_t n)
205205
{
206206
char *ptr = NULL;
207207

208-
assert(pool && str && pool->item_size == sizeof(char));
208+
GIT_ASSERT_ARG_WITH_RETVAL(pool, NULL);
209+
GIT_ASSERT_ARG_WITH_RETVAL(str, NULL);
210+
GIT_ASSERT_ARG_WITH_RETVAL(pool->item_size == sizeof(char), NULL);
209211

210212
if (n == SIZE_MAX)
211213
return NULL;
@@ -220,7 +222,10 @@ char *git_pool_strndup(git_pool *pool, const char *str, size_t n)
220222

221223
char *git_pool_strdup(git_pool *pool, const char *str)
222224
{
223-
assert(pool && str && pool->item_size == sizeof(char));
225+
GIT_ASSERT_ARG_WITH_RETVAL(pool, NULL);
226+
GIT_ASSERT_ARG_WITH_RETVAL(str, NULL);
227+
GIT_ASSERT_ARG_WITH_RETVAL(pool->item_size == sizeof(char), NULL);
228+
224229
return git_pool_strndup(pool, str, strlen(str));
225230
}
226231

@@ -234,7 +239,8 @@ char *git_pool_strcat(git_pool *pool, const char *a, const char *b)
234239
void *ptr;
235240
size_t len_a, len_b, total;
236241

237-
assert(pool && pool->item_size == sizeof(char));
242+
GIT_ASSERT_ARG_WITH_RETVAL(pool, NULL);
243+
GIT_ASSERT_ARG_WITH_RETVAL(pool->item_size == sizeof(char), NULL);
238244

239245
len_a = a ? strlen(a) : 0;
240246
len_b = b ? strlen(b) : 0;

0 commit comments

Comments
 (0)