Skip to content

Instantly share code, notes, and snippets.

@sergot
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergot/56e74cff08f2fa2c64a8 to your computer and use it in GitHub Desktop.
Save sergot/56e74cff08f2fa2c64a8 to your computer and use it in GitHub Desktop.
diff --git a/src/6model/reprs/CPPStruct.c b/src/6model/reprs/CPPStruct.c
index 9373909..53b5ac9 100644
--- a/src/6model/reprs/CPPStruct.c
+++ b/src/6model/reprs/CPPStruct.c
@@ -320,8 +320,8 @@ static void initialize(MVMThreadContext *tc, MVMSTable *st, MVMObject *root, voi
/* Allocate object body. */
MVMCPPStructBody *body = (MVMCPPStructBody *)data;
- body->cppstruct = MVM_malloc(repr_data->struct_size > 0 ? repr_data->struct_size : 1);
- memset(body->cppstruct, 0, repr_data->struct_size);
+ size_t size = repr_data->struct_size > 0 ? repr_data->struct_size : 1;
+ body->cppstruct = MVM_calloc(1, size);
/* Allocate child obj array. */
if (repr_data->num_child_objs > 0)
diff --git a/src/6model/reprs/CStruct.c b/src/6model/reprs/CStruct.c
index 04bb654..459b6ae 100644
--- a/src/6model/reprs/CStruct.c
+++ b/src/6model/reprs/CStruct.c
@@ -314,8 +314,8 @@ static void initialize(MVMThreadContext *tc, MVMSTable *st, MVMObject *root, voi
/* Allocate object body. */
MVMCStructBody *body = (MVMCStructBody *)data;
- body->cstruct = MVM_malloc(repr_data->struct_size > 0 ? repr_data->struct_size : 1);
- memset(body->cstruct, 0, repr_data->struct_size);
+ size_t size = repr_data->struct_size > 0 ? repr_data->struct_size : 1;
+ body->cstruct = MVM_calloc(1, size);
/* Allocate child obj array. */
if (repr_data->num_child_objs > 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment