blob: b312307d1770ea5bab6a784ade27f41f0ea0cc52 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
/* See LICENSE file for copyright and license details. */
#include "internals"
#include <string.h>
size_t
zsave(z_t a, void *buffer)
{
if (buffer) {
char *buf = 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) {
memcpy(buf, a->chars, a->used * sizeof(*(a->chars)));
}
}
return sizeof(z_t) - sizeof(a->chars) + (a->sign ? a->used * sizeof(*(a->chars)) : 0);
}
|