libzahl

big integer library
git clone git://git.suckless.org/libzahl
Log | Files | Refs | README | LICENSE

commit ee47da9c3992a846f3fb236e7796dbb88d44819c
parent d703af0b0afa6eafefe95b56b4073c3a16c46be3
Author: Mattias Andrée <maandree@kth.se>
Date:   Tue,  1 Mar 2016 18:54:58 +0100

Avoid using the internal structure as much as possible

Signed-off-by: Mattias Andrée <maandree@kth.se>

Diffstat:
Msrc/zload.c | 4++--
Msrc/zsave.c | 4++--
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/zload.c b/src/zload.c @@ -17,8 +17,8 @@ zload(z_t a, const void *buffer) } else { a->chars = 0; } - if (a->sign) { + if (!zzero(a)) { memcpy(a->chars, buf, a->used * sizeof(*(a->chars))); } - return sizeof(z_t) - sizeof(a->chars) + (a->sign ? a->used * sizeof(*(a->chars)) : 0); + return sizeof(z_t) - sizeof(a->chars) + (zzero(a) ? 0 : a->used * sizeof(*(a->chars))); } diff --git a/src/zsave.c b/src/zsave.c @@ -12,9 +12,9 @@ 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 (a->sign) { + if (!zzero(a)) { memcpy(buf, a->chars, a->used * sizeof(*(a->chars))); } } - return sizeof(z_t) - sizeof(a->chars) + (a->sign ? a->used * sizeof(*(a->chars)) : 0); + return sizeof(z_t) - sizeof(a->chars) + (zzero(a) ? 0 : a->used * sizeof(*(a->chars))); }