1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-25 17:57:17 +00:00

Fix buffer allocation

This commit is contained in:
J.-F. Cap 2019-02-26 00:21:03 +01:00
parent fb5119bf43
commit 3eb44f1f79

View File

@ -83,11 +83,14 @@ static JanetTArrayType get_ta_type_by_name(const uint8_t *name) {
static JanetTArrayBuffer *ta_buffer_init(JanetTArrayBuffer *buf, size_t size) { static JanetTArrayBuffer *ta_buffer_init(JanetTArrayBuffer *buf, size_t size) {
buf->data = NULL;
if (size > 0) {
buf->data = (uint8_t *)calloc(size, sizeof(uint8_t)); buf->data = (uint8_t *)calloc(size, sizeof(uint8_t));
if (buf->data == NULL) {
JANET_OUT_OF_MEMORY;
}
}
buf->size = size; buf->size = size;
#ifdef JANET_BIG_ENDIAN #ifdef JANET_BIG_ENDIAN
buf->flags = TA_FLAG_BIG_ENDIAN; buf->flags = TA_FLAG_BIG_ENDIAN;