@@ -1620,7 +1620,7 @@ get_target_path(HANDLE hdl, wchar_t **target_path)
1620
1620
if (!buf_size )
1621
1621
return FALSE;
1622
1622
1623
- buf = (wchar_t * ) PyMem_Malloc (( buf_size + 1 ) * sizeof ( wchar_t ) );
1623
+ buf = PyMem_New (wchar_t , buf_size + 1 );
1624
1624
if (!buf ) {
1625
1625
SetLastError (ERROR_OUTOFMEMORY );
1626
1626
return FALSE;
@@ -4472,7 +4472,7 @@ _listdir_windows_no_opendir(path_t *path, PyObject *list)
4472
4472
len = wcslen (path -> wide );
4473
4473
}
4474
4474
/* The +5 is so we can append "\\*.*\0" */
4475
- wnamebuf = PyMem_Malloc (( len + 5 ) * sizeof ( wchar_t ) );
4475
+ wnamebuf = PyMem_New ( wchar_t , len + 5 );
4476
4476
if (!wnamebuf ) {
4477
4477
PyErr_NoMemory ();
4478
4478
goto exit ;
@@ -4809,7 +4809,7 @@ posix__getfullpathname(PyObject *self, PyObject *args)
4809
4809
Py_ARRAY_LENGTH (woutbuf ),
4810
4810
woutbuf , & wtemp );
4811
4811
if (result > Py_ARRAY_LENGTH (woutbuf )) {
4812
- woutbufp = PyMem_Malloc ( result * sizeof ( wchar_t ) );
4812
+ woutbufp = PyMem_New ( wchar_t , result );
4813
4813
if (!woutbufp )
4814
4814
return PyErr_NoMemory ();
4815
4815
result = GetFullPathNameW (wpath , result , woutbufp , & wtemp );
@@ -4923,7 +4923,7 @@ os__getfinalpathname_impl(PyModuleDef *module, PyObject *path)
4923
4923
if (!buf_size )
4924
4924
return win32_error_object ("GetFinalPathNameByHandle" , path );
4925
4925
4926
- target_path = (wchar_t * ) PyMem_Malloc (( buf_size + 1 ) * sizeof ( wchar_t ) );
4926
+ target_path = PyMem_New (wchar_t , buf_size + 1 );
4927
4927
if (!target_path )
4928
4928
return PyErr_NoMemory ();
4929
4929
@@ -5041,7 +5041,7 @@ os__getvolumepathname_impl(PyModuleDef *module, PyObject *path)
5041
5041
return NULL ;
5042
5042
}
5043
5043
5044
- mountpath = (wchar_t * ) PyMem_Malloc ( buflen * sizeof ( wchar_t ) );
5044
+ mountpath = PyMem_New (wchar_t , buflen );
5045
5045
if (mountpath == NULL )
5046
5046
return PyErr_NoMemory ();
5047
5047
@@ -8421,9 +8421,9 @@ posix_getgrouplist(PyObject *self, PyObject *args)
8421
8421
#endif
8422
8422
8423
8423
#ifdef __APPLE__
8424
- groups = PyMem_Malloc ( ngroups * sizeof ( int ) );
8424
+ groups = PyMem_New ( int , ngroups );
8425
8425
#else
8426
- groups = PyMem_Malloc ( ngroups * sizeof ( gid_t ) );
8426
+ groups = PyMem_New ( gid_t , ngroups );
8427
8427
#endif
8428
8428
if (groups == NULL )
8429
8429
return PyErr_NoMemory ();
@@ -8523,7 +8523,7 @@ os_getgroups_impl(PyModuleDef *module)
8523
8523
/* groups will fit in existing array */
8524
8524
alt_grouplist = grouplist ;
8525
8525
} else {
8526
- alt_grouplist = PyMem_Malloc ( n * sizeof ( gid_t ) );
8526
+ alt_grouplist = PyMem_New ( gid_t , n );
8527
8527
if (alt_grouplist == NULL ) {
8528
8528
errno = EINVAL ;
8529
8529
return posix_error ();
@@ -8549,7 +8549,7 @@ os_getgroups_impl(PyModuleDef *module)
8549
8549
/* Avoid malloc(0) */
8550
8550
alt_grouplist = grouplist ;
8551
8551
} else {
8552
- alt_grouplist = PyMem_Malloc ( n * sizeof ( gid_t ) );
8552
+ alt_grouplist = PyMem_New ( gid_t , n );
8553
8553
if (alt_grouplist == NULL ) {
8554
8554
errno = EINVAL ;
8555
8555
return posix_error ();
0 commit comments