diff --git a/src/compile.c b/src/compile.c index 467ea2b0ad..e5e65f2014 100644 --- a/src/compile.c +++ b/src/compile.c @@ -1282,7 +1282,7 @@ static int compile(struct bytecode* bc, block b, struct locfile* lf, jv args, jv bc->codelen = pos; bc->debuginfo = jv_object_set(bc->debuginfo, jv_string("locals"), localnames); if (bc->nsubfunctions && !errors) { - bc->subfunctions = jv_mem_calloc(sizeof(struct bytecode*), bc->nsubfunctions); + bc->subfunctions = jv_mem_calloc(bc->nsubfunctions, sizeof(struct bytecode*)); for (inst* curr = b.first; curr; curr = curr->next) { if (curr->op == CLOSURE_CREATE) { struct bytecode* subfn = jv_mem_alloc(sizeof(struct bytecode)); @@ -1308,7 +1308,7 @@ static int compile(struct bytecode* bc, block b, struct locfile* lf, jv args, jv bc->nsubfunctions = 0; bc->subfunctions = 0; } - uint16_t* code = jv_mem_calloc(sizeof(uint16_t), bc->codelen); + uint16_t* code = jv_mem_calloc(bc->codelen, sizeof(uint16_t)); bc->code = code; pos = 0; jv constant_pool = jv_array(); @@ -1374,7 +1374,7 @@ int block_compile(block b, struct bytecode** out, struct locfile* lf, jv args) { bc->globals = jv_mem_alloc(sizeof(struct symbol_table)); int ncfunc = count_cfunctions(b); bc->globals->ncfunctions = 0; - bc->globals->cfunctions = jv_mem_calloc(sizeof(struct cfunction), ncfunc); + bc->globals->cfunctions = jv_mem_calloc(ncfunc, sizeof(struct cfunction)); bc->globals->cfunc_names = jv_array(); bc->debuginfo = jv_object_set(jv_object(), jv_string("name"), jv_null()); jv env = jv_invalid(); diff --git a/src/jv_aux.c b/src/jv_aux.c index eedaaeb7cc..6004799c6a 100644 --- a/src/jv_aux.c +++ b/src/jv_aux.c @@ -553,7 +553,7 @@ jv jv_keys_unsorted(jv x) { jv jv_keys(jv x) { if (jv_get_kind(x) == JV_KIND_OBJECT) { int nkeys = jv_object_length(jv_copy(x)); - jv* keys = jv_mem_calloc(sizeof(jv), nkeys); + jv* keys = jv_mem_calloc(nkeys, sizeof(jv)); int kidx = 0; jv_object_foreach(x, key, value) { keys[kidx++] = key; @@ -674,7 +674,7 @@ static struct sort_entry* sort_items(jv objects, jv keys) { assert(jv_get_kind(keys) == JV_KIND_ARRAY); assert(jv_array_length(jv_copy(objects)) == jv_array_length(jv_copy(keys))); int n = jv_array_length(jv_copy(objects)); - struct sort_entry* entries = jv_mem_calloc(sizeof(struct sort_entry), n); + struct sort_entry* entries = jv_mem_calloc(n, sizeof(struct sort_entry)); for (int i=0; inlines++; } - l->linemap = jv_mem_calloc(sizeof(int), (l->nlines + 1)); + l->linemap = jv_mem_calloc(l->nlines + 1, sizeof(int)); l->linemap[0] = 0; int line = 1; for (int i=0; i