aboutsummaryrefslogtreecommitdiffstats
path: root/src/zload.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-03-04 23:50:00 +0100
committerMattias Andrée <maandree@kth.se>2016-03-04 23:50:00 +0100
commit76d0af5599554d11f104d582cdac8fbaa8569fcc (patch)
tree0ed9889a86d52ebd208382f2fd49dad0570d1f8c /src/zload.c
parentClean up, fix a few bugs, and add a test (diff)
downloadlibzahl-76d0af5599554d11f104d582cdac8fbaa8569fcc.tar.gz
libzahl-76d0af5599554d11f104d582cdac8fbaa8569fcc.tar.bz2
libzahl-76d0af5599554d11f104d582cdac8fbaa8569fcc.tar.xz
Clean up, add zerror and zperror, fix bugs and add more tests
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/zload.c')
-rw-r--r--src/zload.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/zload.c b/src/zload.c
index ff54afb..a77ae57 100644
--- a/src/zload.c
+++ b/src/zload.c
@@ -6,15 +6,14 @@ size_t
zload(z_t a, const void *buffer)
{
const char *buf = buffer;
- 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);
+ a->alloced = 0;
+ if (a->sign)
+ ENSURE_SIZE(a, a->used);
else
a->chars = 0;
if (!zzero(a))
zmemcpy(a->chars, buf, a->used);
- return sizeof(z_t) - sizeof(a->chars) + (zzero(a) ? 0 : a->used * sizeof(*(a->chars)));
+ return sizeof(int) + sizeof(size_t) + (zzero(a) ? 0 : a->used * sizeof(zahl_char_t));
}