summaryrefslogtreecommitdiffstats
path: root/lib/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/buffer.c')
-rw-r--r--lib/buffer.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/buffer.c b/lib/buffer.c
index fda2fc8..cc863fa 100644
--- a/lib/buffer.c
+++ b/lib/buffer.c
@@ -11,7 +11,7 @@
void ul_buffer_reset_data(struct ul_buffer *buf)
{
if (buf->begin)
- buf->begin[0] = '\0';
+ memset(buf->begin, 0, buf->sz);
buf->end = buf->begin;
if (buf->ptrs && buf->nptrs)
@@ -49,7 +49,7 @@ int ul_buffer_is_empty(struct ul_buffer *buf)
int ul_buffer_save_pointer(struct ul_buffer *buf, unsigned short ptr_idx)
{
if (ptr_idx >= buf->nptrs) {
- char **tmp = realloc(buf->ptrs, (ptr_idx + 1) * sizeof(char *));
+ char **tmp = reallocarray(buf->ptrs, ptr_idx + 1, sizeof(char *));
if (!tmp)
return -EINVAL;
@@ -134,12 +134,11 @@ int ul_buffer_append_data(struct ul_buffer *buf, const char *data, size_t sz)
if (!buf)
return -EINVAL;
- if (!data || !*data)
+ if (!data)
return 0;
if (buf->begin && buf->end)
maxsz = buf->sz - (buf->end - buf->begin);
-
if (maxsz <= sz + 1) {
int rc = ul_buffer_alloc_data(buf, buf->sz + sz + 1);
if (rc)