Skip to content

Commit

Permalink
Change MVM_calloc(1, f * b) into MVM_calloc(f, b)
Browse files Browse the repository at this point in the history
Better, because calloc will check for overflow.
  • Loading branch information
MasterDuke17 committed Jan 14, 2017
1 parent 6477d61 commit f69bfbd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/core/bytecodedump.c
Expand Up @@ -65,7 +65,7 @@ char * MVM_bytecode_dump(MVMThreadContext *tc, MVMCompUnit *cu) {
MVMuint32 s = 1024;
MVMuint32 l = 0;
MVMuint32 i, j, k;
char *o = MVM_calloc(1, sizeof(char) * s);
char *o = MVM_calloc(s, sizeof(char));
char ***frame_lexicals = MVM_malloc(sizeof(char **) * cu->body.num_frames);
MVMString *name = MVM_string_utf8_decode(tc, tc->instance->VMString, "", 0);

Expand Down Expand Up @@ -199,7 +199,7 @@ char * MVM_bytecode_dump(MVMThreadContext *tc, MVMCompUnit *cu) {
/* allocate a line buffer */
s = 200;
l = 0;
o = MVM_calloc(1, sizeof(char) * s);
o = MVM_calloc(s, sizeof(char));

lineloc = cur_op - bytecode_start;
/* mark that this line starts at this point in the bytestream */
Expand Down
2 changes: 1 addition & 1 deletion src/gc/gen2.c
Expand Up @@ -6,7 +6,7 @@ MVMGen2Allocator * MVM_gc_gen2_create(MVMInstance *i) {
MVMGen2Allocator *al = MVM_malloc(sizeof(MVMGen2Allocator));

/* Create empty size classes array data structure. */
al->size_classes = (MVMGen2SizeClass *)MVM_calloc(1, sizeof(MVMGen2SizeClass) * MVM_GEN2_BINS);
al->size_classes = (MVMGen2SizeClass *)MVM_calloc(MVM_GEN2_BINS, sizeof(MVMGen2SizeClass));

/* Set up overflows area. */
al->alloc_overflows = MVM_GEN2_OVERFLOWS;
Expand Down

0 comments on commit f69bfbd

Please sign in to comment.