-
-
Save sergot/56e74cff08f2fa2c64a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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