From be2689e710fd864ca89f8821cc44d836ac6f91ff Mon Sep 17 00:00:00 2001 From: Alina Lenk Date: Sun, 3 Jul 2022 19:21:53 +0200 Subject: [PATCH 2/2] generate_packets.py: Use FC_FREE() macro See osdn#44993 Signed-off-by: Alina Lenk --- common/generate_packets.py | 39 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/common/generate_packets.py b/common/generate_packets.py index 6242c50b55..2c2184e6b3 100755 --- a/common/generate_packets.py +++ b/common/generate_packets.py @@ -747,8 +747,7 @@ DIO_PUT({self.dataio_type}, &dout, &field_addr, real_packet->{self.name}[i]); #ifdef FREECIV_JSON_CONNECTION /* Exit diff array element. */ - free(field_addr.sub_location->sub_location); - field_addr.sub_location->sub_location = NULL; + FC_FREE(field_addr.sub_location->sub_location); #endif /* FREECIV_JSON_CONNECTION */ }} }} @@ -769,12 +768,10 @@ DIO_PUT({self.dataio_type}, &dout, &field_addr, real_packet->{self.name}[i]); #ifdef FREECIV_JSON_CONNECTION /* Exit diff array element. */ - free(field_addr.sub_location->sub_location); - field_addr.sub_location->sub_location = NULL; + FC_FREE(field_addr.sub_location->sub_location); /* Exit array. */ - free(field_addr.sub_location); - field_addr.sub_location = NULL; + FC_FREE(field_addr.sub_location); #endif /* FREECIV_JSON_CONNECTION */ }} """.format(self = self, c = c) @@ -814,15 +811,13 @@ DIO_PUT({self.dataio_type}, &dout, &field_addr, real_packet->{self.name}[i]); #ifdef FREECIV_JSON_CONNECTION /* Exit the inner array. */ - free(field_addr.sub_location->sub_location); - field_addr.sub_location->sub_location = NULL; + FC_FREE(field_addr.sub_location->sub_location); #endif /* FREECIV_JSON_CONNECTION */ }} #ifdef FREECIV_JSON_CONNECTION /* Exit the outer array. */ - free(field_addr.sub_location); - field_addr.sub_location = NULL; + FC_FREE(field_addr.sub_location); #endif /* FREECIV_JSON_CONNECTION */ }} """.format(self = self, c = c) @@ -849,8 +844,7 @@ DIO_PUT({self.dataio_type}, &dout, &field_addr, real_packet->{self.name}[i]); #ifdef FREECIV_JSON_CONNECTION /* Exit array. */ - free(field_addr.sub_location); - field_addr.sub_location = NULL; + FC_FREE(field_addr.sub_location); #endif /* FREECIV_JSON_CONNECTION */ }} """.format(c = c, array_size_u = array_size_u) @@ -1054,15 +1048,13 @@ if (!DIO_GET({self.dataio_type}, &din, &field_addr, &real_packet->{self.name})) #ifdef FREECIV_JSON_CONNECTION /* Exit inner array. */ - free(field_addr.sub_location->sub_location); - field_addr.sub_location->sub_location = NULL; + FC_FREE(field_addr.sub_location->sub_location); #endif /* FREECIV_JSON_CONNECTION */ }} #ifdef FREECIV_JSON_CONNECTION /* Exit outer array. */ - free(field_addr.sub_location); - field_addr.sub_location = NULL; + FC_FREE(field_addr.sub_location); #endif /* FREECIV_JSON_CONNECTION */ }} """.format(self = self, c = c, extra = extra) @@ -1086,8 +1078,7 @@ if (!DIO_GET({self.dataio_type}, &din, &field_addr, &real_packet->{self.name})) #ifdef FREECIV_JSON_CONNECTION /* Exit array. */ - free(field_addr.sub_location); - field_addr.sub_location = NULL; + FC_FREE(field_addr.sub_location); #endif /* FREECIV_JSON_CONNECTION */ }} """.format(array_size_u = array_size_u, c = c, extra = extra) @@ -1118,12 +1109,10 @@ while (TRUE) {{ if (i == 255) {{ #ifdef FREECIV_JSON_CONNECTION /* Exit diff array element. */ - free(field_addr.sub_location->sub_location); - field_addr.sub_location->sub_location = NULL; + FC_FREE(field_addr.sub_location->sub_location); /* Exit diff array. */ - free(field_addr.sub_location); - field_addr.sub_location = NULL; + FC_FREE(field_addr.sub_location); #endif /* FREECIV_JSON_CONNECTION */ break; @@ -1143,15 +1132,13 @@ while (TRUE) {{ #ifdef FREECIV_JSON_CONNECTION /* Exit diff array element. */ - free(field_addr.sub_location->sub_location); - field_addr.sub_location->sub_location = NULL; + FC_FREE(field_addr.sub_location->sub_location); #endif /* FREECIV_JSON_CONNECTION */ }} #ifdef FREECIV_JSON_CONNECTION /* Exit array. */ -free(field_addr.sub_location); -field_addr.sub_location = NULL; +FC_FREE(field_addr.sub_location); #endif /* FREECIV_JSON_CONNECTION */ }} """.format(self = self, array_size_u = array_size_u, c = c) -- 2.34.1