diff options
Diffstat (limited to 'src/zload.c')
| -rw-r--r-- | src/zload.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/zload.c b/src/zload.c index e03d911..0f5d35b 100644 --- a/src/zload.c +++ b/src/zload.c @@ -1,9 +1,6 @@ /* See LICENSE file for copyright and license details. */ #include "internals" -#include <stdlib.h> -#include <string.h> - size_t zload(z_t a, const void *buffer) @@ -12,13 +9,11 @@ zload(z_t a, const void *buffer) a->sign = *((int *)buf), buf += sizeof(int); a->used = *((size_t *)buf), buf += sizeof(size_t); a->alloced = *((size_t *)buf), buf += sizeof(size_t); - if (a->alloced) { - a->chars = realloc(a->chars, a->alloced * sizeof(*(a->chars))); - } else { + if (a->alloced) + zahl_realloc(a, a->alloced); + else a->chars = 0; - } - if (!zzero(a)) { - memcpy(a->chars, buf, a->used * sizeof(*(a->chars))); - } + if (!zzero(a)) + zmemcpy(a->chars, buf, a->used); return sizeof(z_t) - sizeof(a->chars) + (zzero(a) ? 0 : a->used * sizeof(*(a->chars))); } |
