aboutsummaryrefslogtreecommitdiffstats
path: root/src/ztrunc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ztrunc.c')
-rw-r--r--src/ztrunc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/ztrunc.c b/src/ztrunc.c
index ffbbbe0..f86fb8e 100644
--- a/src/ztrunc.c
+++ b/src/ztrunc.c
@@ -18,9 +18,10 @@ ztrunc(z_t a, z_t b, size_t bits)
a->used = MIN(chars, b->used);
if (a->used < chars)
bits = 0;
- if (a->alloced < b->alloced)
- zahl_realloc(a, b->alloced);
- zmemcpy(a->chars, b->chars, a->used);
+ if (a != b) {
+ ENSURE_SIZE(a, b->alloced);
+ zmemcpy(a->chars, b->chars, a->used);
+ }
bits = BITS_IN_LAST_CHAR(bits);
if (bits) {
mask <<= bits;