@@ -1042,13 +1042,12 @@ load_data(zoneinfo_state *state, PyZoneInfo_ZoneInfo *self, PyObject *file_obj)
10421042 self -> num_ttinfos = (size_t )num_ttinfos ;
10431043
10441044 // Load the transition indices and list
1045- self -> trans_list_utc =
1046- PyMem_Malloc (self -> num_transitions * sizeof (int64_t ));
1045+ self -> trans_list_utc = PyMem_New (int64_t , self -> num_transitions );
10471046 if (self -> trans_list_utc == NULL ) {
10481047 PyErr_NoMemory ();
10491048 goto error ;
10501049 }
1051- trans_idx = PyMem_Malloc ( self -> num_transitions * sizeof ( Py_ssize_t ) );
1050+ trans_idx = PyMem_New ( Py_ssize_t , self -> num_transitions );
10521051 if (trans_idx == NULL ) {
10531052 PyErr_NoMemory ();
10541053 goto error ;
@@ -1086,8 +1085,8 @@ load_data(zoneinfo_state *state, PyZoneInfo_ZoneInfo *self, PyObject *file_obj)
10861085 }
10871086
10881087 // Load UTC offsets and isdst (size num_ttinfos)
1089- utcoff = PyMem_Malloc ( self -> num_ttinfos * sizeof ( long ) );
1090- isdst = PyMem_Malloc ( self -> num_ttinfos * sizeof ( unsigned char ) );
1088+ utcoff = PyMem_New ( long , self -> num_ttinfos );
1089+ isdst = PyMem_New ( unsigned char , self -> num_ttinfos );
10911090
10921091 if (utcoff == NULL || isdst == NULL ) {
10931092 PyErr_NoMemory ();
@@ -1135,7 +1134,7 @@ load_data(zoneinfo_state *state, PyZoneInfo_ZoneInfo *self, PyObject *file_obj)
11351134 }
11361135
11371136 // Build _ttinfo objects from utcoff, dstoff and abbr
1138- self -> _ttinfos = PyMem_Malloc ( self -> num_ttinfos * sizeof ( _ttinfo ) );
1137+ self -> _ttinfos = PyMem_New ( _ttinfo , self -> num_ttinfos );
11391138 if (self -> _ttinfos == NULL ) {
11401139 PyErr_NoMemory ();
11411140 goto error ;
@@ -2148,7 +2147,7 @@ ts_to_local(size_t *trans_idx, int64_t *trans_utc, long *utcoff,
21482147
21492148 // Copy the UTC transitions into each array to be modified in place later
21502149 for (size_t i = 0 ; i < 2 ; ++ i ) {
2151- trans_local [i ] = PyMem_Malloc ( num_transitions * sizeof ( int64_t ) );
2150+ trans_local [i ] = PyMem_New ( int64_t , num_transitions );
21522151 if (trans_local [i ] == NULL ) {
21532152 PyErr_NoMemory ();
21542153 return -1 ;
0 commit comments