summaryrefslogtreecommitdiff
path: root/src/buffer.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2020-04-05 10:23:20 +0100
committerEdward Thomson <ethomson@edwardthomson.com>2020-11-25 11:42:03 +0000
commita6dd58659d16207ec92a1f4d87ec620236ce4a23 (patch)
tree044361c631851b3f291d4efd287298481e0dab12 /src/buffer.c
parent7d24070d7a8b5e6d0a37b6b874d9000cd4e388bc (diff)
downloadlibgit2-a6dd58659d16207ec92a1f4d87ec620236ce4a23.tar.gz
buffer: use GIT_ASSERT
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c19
1 files changed, 11 insertions, 8 deletions
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;