aboutsummaryrefslogtreecommitdiffstats
path: root/src/zsave.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-03-03 23:02:59 +0100
committerMattias Andrée <maandree@kth.se>2016-03-03 23:02:59 +0100
commitd6987458f21cf1890045f2606d0f8ec4d2225b44 (patch)
tree90afabbea01b01c4dedcb41748eb534ce04fbf77 /src/zsave.c
parentzsets: minor optimisation (diff)
downloadlibzahl-d6987458f21cf1890045f2606d0f8ec4d2225b44.tar.gz
libzahl-d6987458f21cf1890045f2606d0f8ec4d2225b44.tar.bz2
libzahl-d6987458f21cf1890045f2606d0f8ec4d2225b44.tar.xz
Cleanup and fix bug in ztrunc
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/zsave.c')
-rw-r--r--src/zsave.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/zsave.c b/src/zsave.c
index 6aa50b5..405e7af 100644
--- a/src/zsave.c
+++ b/src/zsave.c
@@ -1,8 +1,6 @@
/* See LICENSE file for copyright and license details. */
#include "internals"
-#include <string.h>
-
size_t
zsave(z_t a, void *buffer)
@@ -12,9 +10,8 @@ zsave(z_t a, void *buffer)
*((int *)buf) = a->sign, buf += sizeof(int);
*((size_t *)buf) = a->used, buf += sizeof(size_t);
*((size_t *)buf) = a->alloced, buf += sizeof(size_t);
- if (!zzero(a)) {
- memcpy(buf, a->chars, a->used * sizeof(*(a->chars)));
- }
+ if (!zzero(a))
+ zmemcpy(buf, a->chars, a->used);
}
return sizeof(z_t) - sizeof(a->chars) + (zzero(a) ? 0 : a->used * sizeof(*(a->chars)));
}