From aff09967d194d062ae8d83c0fbe1edf158804ef9 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 4 Mar 2016 10:45:10 +0100 Subject: Clean up, fix a few bugs, and add a test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/zload.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/zload.c') diff --git a/src/zload.c b/src/zload.c index c708453..ff54afb 100644 --- a/src/zload.c +++ b/src/zload.c @@ -6,11 +6,12 @@ size_t zload(z_t a, const void *buffer) { const char *buf = buffer; - a->sign = *((const int *)buf), buf += sizeof(int); - a->used = *((const size_t *)buf), buf += sizeof(size_t); - a->alloced = *((const size_t *)buf), buf += sizeof(size_t); - if (a->alloced) - zahl_realloc(a, a->alloced); + size_t alloced; + a->sign = *((const int *)buf), buf += sizeof(int); + a->used = *((const size_t *)buf), buf += sizeof(size_t); + alloced = *((const size_t *)buf), buf += sizeof(size_t); + if (alloced) + ENSURE_SIZE(a, alloced); else a->chars = 0; if (!zzero(a)) -- cgit v1.2.3-70-g09d2