diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2020-04-05 10:23:20 +0100 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2020-11-25 11:42:03 +0000 |
| commit | a6dd58659d16207ec92a1f4d87ec620236ce4a23 (patch) | |
| tree | 044361c631851b3f291d4efd287298481e0dab12 | |
| parent | 7d24070d7a8b5e6d0a37b6b874d9000cd4e388bc (diff) | |
| download | libgit2-a6dd58659d16207ec92a1f4d87ec620236ce4a23.tar.gz | |
buffer: use GIT_ASSERT
| -rw-r--r-- | src/buf_text.c | 4 | ||||
| -rw-r--r-- | src/buffer.c | 19 |
2 files changed, 13 insertions, 10 deletions
diff --git a/src/buf_text.c b/src/buf_text.c index 88fcb87dd..0fd22319f 100644 --- a/src/buf_text.c +++ b/src/buf_text.c @@ -69,7 +69,7 @@ int git_buf_text_crlf_to_lf(git_buf *tgt, const git_buf *src) size_t new_size; char *out; - assert(tgt != src); + GIT_ASSERT(tgt != src); if (!next) return git_buf_set(tgt, src->ptr, src->size); @@ -116,7 +116,7 @@ int git_buf_text_lf_to_crlf(git_buf *tgt, const git_buf *src) const char *next = memchr(scan, '\n', src->size); size_t alloclen; - assert(tgt != src); + GIT_ASSERT(tgt != src); if (!next) return git_buf_set(tgt, src->ptr, src->size); diff --git a/src/buffer.c b/src/buffer.c index c203650c7..f395a77cc 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -225,7 +225,7 @@ int git_buf_put(git_buf *buf, const char *data, size_t len) if (len) { size_t new_size; - assert(data); + GIT_ASSERT_ARG(data); GIT_ERROR_CHECK_ALLOC_ADD(&new_size, buf->size, len); GIT_ERROR_CHECK_ALLOC_ADD(&new_size, new_size, 1); @@ -239,7 +239,8 @@ int git_buf_put(git_buf *buf, const char *data, size_t len) int git_buf_puts(git_buf *buf, const char *string) { - assert(string); + GIT_ASSERT_ARG(string); + return git_buf_put(buf, string, strlen(string)); } @@ -319,7 +320,7 @@ int git_buf_decode_base64(git_buf *buf, const char *base64, size_t len) return -1; } - assert(len % 4 == 0); + GIT_ASSERT_ARG(len % 4 == 0); GIT_ERROR_CHECK_ALLOC_ADD(&new_size, (len / 4 * 3), buf->size); GIT_ERROR_CHECK_ALLOC_ADD(&new_size, new_size, 1); ENSURE_SIZE(buf, new_size); @@ -760,7 +761,7 @@ int git_buf_join( /* not safe to have str_b point internally to the buffer */ if (buf->size) - assert(str_b < buf->ptr || str_b >= buf->ptr + buf->size); + GIT_ASSERT_ARG(str_b < buf->ptr || str_b >= buf->ptr + buf->size); /* figure out if we need to insert a separator */ if (separator && strlen_a) { @@ -810,9 +811,9 @@ int git_buf_join3( char *tgt; /* for this function, disallow pointers into the existing buffer */ - assert(str_a < buf->ptr || str_a >= buf->ptr + buf->size); - assert(str_b < buf->ptr || str_b >= buf->ptr + buf->size); - assert(str_c < buf->ptr || str_c >= buf->ptr + buf->size); + GIT_ASSERT(str_a < buf->ptr || str_a >= buf->ptr + buf->size); + GIT_ASSERT(str_b < buf->ptr || str_b >= buf->ptr + buf->size); + GIT_ASSERT(str_c < buf->ptr || str_c >= buf->ptr + buf->size); if (separator) { if (len_a > 0) { @@ -885,7 +886,9 @@ int git_buf_splice( char *splice_loc; size_t new_size, alloc_size; - assert(buf && where <= buf->size && nb_to_remove <= buf->size - where); + GIT_ASSERT(buf); + GIT_ASSERT(where <= buf->size); + GIT_ASSERT(nb_to_remove <= buf->size - where); splice_loc = buf->ptr + where; |
