mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-12-26 17:23:38 +00:00
This commit is contained in:
commit
aa0b8732aa
2 changed files with 4 additions and 4 deletions
6
xs.h
6
xs.h
|
@ -1057,12 +1057,12 @@ xs_data *xs_data_new(const void *data, int size)
|
||||||
xs_data *v;
|
xs_data *v;
|
||||||
|
|
||||||
/* add the overhead (data type + 24bit size) */
|
/* add the overhead (data type + 24bit size) */
|
||||||
size += 4;
|
int total_size = size + 4;
|
||||||
|
|
||||||
v = xs_realloc(NULL, _xs_blk_size(size));
|
v = xs_realloc(NULL, _xs_blk_size(total_size));
|
||||||
v[0] = XSTYPE_DATA;
|
v[0] = XSTYPE_DATA;
|
||||||
|
|
||||||
_xs_put_24b(v + 1, size);
|
_xs_put_24b(v + 1, total_size);
|
||||||
|
|
||||||
memcpy(&v[4], data, size);
|
memcpy(&v[4], data, size);
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ static int _data_callback(void *buffer, size_t size,
|
||||||
|
|
||||||
/* open space */
|
/* open space */
|
||||||
pd->size += sz;
|
pd->size += sz;
|
||||||
pd->data = xs_realloc(pd->data, pd->size + 1);
|
pd->data = xs_realloc(pd->data, _xs_blk_size(pd->size + 1));
|
||||||
|
|
||||||
/* copy data */
|
/* copy data */
|
||||||
memcpy(pd->data + pd->offset, buffer, sz);
|
memcpy(pd->data + pd->offset, buffer, sz);
|
||||||
|
|
Loading…
Reference in a new issue