From 787dbbf337bb238bea30d66d4bf43907bca20e19 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 1 Mar 2016 19:22:26 +0100 Subject: Add zcmp, zcmpi, zcmpu, zcmpmag, zset, zseti, and zsetu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/zset.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/zset.c (limited to 'src/zset.c') diff --git a/src/zset.c b/src/zset.c new file mode 100644 index 0000000..3598859 --- /dev/null +++ b/src/zset.c @@ -0,0 +1,22 @@ +/* See LICENSE file for copyright and license details. */ +#include "internals" + +#include +#include + + +void +zset(z_t a, z_t b) +{ + if (zzero(b)) { + SET_SIGNUM(a, 0); + } else { + if (a->alloced < b->alloced) { + a->alloced = b->alloced; + a->chars = realloc(a->chars, b->alloced * sizeof(*(a->chars))); + } + a->sign = b->sign; + a->used = b->used; + memcpy(a->chars, b->chars, b->used * sizeof(*(a->chars))); + } +} -- cgit v1.2.3-70-g09d2