66
77
88static MappedModel_t * MappedModel_create_internal (
9- int another_property ,
9+ int * another_property ,
1010 char * uuid_property
1111 ) {
1212 MappedModel_t * MappedModel_local_var = malloc (sizeof (MappedModel_t ));
1313 if (!MappedModel_local_var ) {
1414 return NULL ;
1515 }
16- MappedModel_local_var -> another_property = another_property ;
16+ memset (MappedModel_local_var , 0 , sizeof (MappedModel_t ));
17+ if (another_property ) {
18+ MappedModel_local_var -> another_property = malloc (sizeof (int ));
19+ if (!MappedModel_local_var -> another_property ) {
20+ MappedModel_free (MappedModel_local_var );
21+ return NULL ;
22+ }
23+ * MappedModel_local_var -> another_property = * another_property ;
24+ }
1725 MappedModel_local_var -> uuid_property = uuid_property ;
1826
1927 MappedModel_local_var -> _library_owned = 1 ;
2028 return MappedModel_local_var ;
2129}
2230
2331__attribute__((deprecated )) MappedModel_t * MappedModel_create (
24- int another_property ,
32+ int * another_property ,
2533 char * uuid_property
2634 ) {
2735 return MappedModel_create_internal (
@@ -39,6 +47,10 @@ void MappedModel_free(MappedModel_t *MappedModel) {
3947 return ;
4048 }
4149 listEntry_t * listEntry ;
50+ if (MappedModel -> another_property ) {
51+ free (MappedModel -> another_property );
52+ MappedModel -> another_property = NULL ;
53+ }
4254 if (MappedModel -> uuid_property ) {
4355 free (MappedModel -> uuid_property );
4456 MappedModel -> uuid_property = NULL ;
@@ -51,7 +63,7 @@ cJSON *MappedModel_convertToJSON(MappedModel_t *MappedModel) {
5163
5264 // MappedModel->another_property
5365 if (MappedModel -> another_property ) {
54- if (cJSON_AddNumberToObject (item , "another_property" , MappedModel -> another_property ) == NULL ) {
66+ if (cJSON_AddNumberToObject (item , "another_property" , * MappedModel -> another_property ) == NULL ) {
5567 goto fail ; //Numeric
5668 }
5769 }
@@ -76,6 +88,9 @@ MappedModel_t *MappedModel_parseFromJSON(cJSON *MappedModelJSON){
7688
7789 MappedModel_t * MappedModel_local_var = NULL ;
7890
91+ // define the local variable for MappedModel->another_property
92+ int * another_property_local_var = NULL ;
93+
7994 // MappedModel->another_property
8095 cJSON * another_property = cJSON_GetObjectItemCaseSensitive (MappedModelJSON , "another_property" );
8196 if (cJSON_IsNull (another_property )) {
@@ -86,6 +101,12 @@ MappedModel_t *MappedModel_parseFromJSON(cJSON *MappedModelJSON){
86101 {
87102 goto end ; //Numeric
88103 }
104+ another_property_local_var = malloc (sizeof (int ));
105+ if (!another_property_local_var )
106+ {
107+ goto end ;
108+ }
109+ * another_property_local_var = another_property -> valuedouble ;
89110 }
90111
91112 // MappedModel->uuid_property
@@ -102,12 +123,16 @@ MappedModel_t *MappedModel_parseFromJSON(cJSON *MappedModelJSON){
102123
103124
104125 MappedModel_local_var = MappedModel_create_internal (
105- another_property ? another_property -> valuedouble : 0 ,
126+ another_property_local_var ,
106127 uuid_property && !cJSON_IsNull (uuid_property ) ? strdup (uuid_property -> valuestring ) : NULL
107128 );
108129
109130 return MappedModel_local_var ;
110131end :
132+ if (another_property_local_var ) {
133+ free (another_property_local_var );
134+ another_property_local_var = NULL ;
135+ }
111136 return NULL ;
112137
113138}
0 commit comments