diff options
| author | Mattias Andrée <maandree@kth.se> | 2016-03-04 10:45:10 +0100 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2016-03-04 10:47:53 +0100 |
| commit | aff09967d194d062ae8d83c0fbe1edf158804ef9 (patch) | |
| tree | 793f32bc01e780bb6457570f9ea7a8e7ff94f7bb /src/zload.c | |
| parent | Add makefile and fix errors (diff) | |
| download | libzahl-aff09967d194d062ae8d83c0fbe1edf158804ef9.tar.gz libzahl-aff09967d194d062ae8d83c0fbe1edf158804ef9.tar.bz2 libzahl-aff09967d194d062ae8d83c0fbe1edf158804ef9.tar.xz | |
Clean up, fix a few bugs, and add a test
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/zload.c')
| -rw-r--r-- | src/zload.c | 11 |
1 files changed, 6 insertions, 5 deletions
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)) |
