buffer: 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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
diff --git a/src/buf_text.c b/src/buf_text.c
index 88fcb87..0fd2231 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 c203650..f395a77 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;