@@ -1638,7 +1638,7 @@ get_target_path(HANDLE hdl, wchar_t **target_path)
1638
1638
if (!buf_size )
1639
1639
return FALSE;
1640
1640
1641
- buf = (wchar_t * ) PyMem_Malloc (( buf_size + 1 ) * sizeof ( wchar_t ) );
1641
+ buf = PyMem_New (wchar_t , buf_size + 1 );
1642
1642
if (!buf ) {
1643
1643
SetLastError (ERROR_OUTOFMEMORY );
1644
1644
return FALSE;
@@ -3627,7 +3627,7 @@ _listdir_windows_no_opendir(path_t *path, PyObject *list)
3627
3627
len = wcslen (path -> wide );
3628
3628
}
3629
3629
/* The +5 is so we can append "\\*.*\0" */
3630
- wnamebuf = PyMem_Malloc (( len + 5 ) * sizeof ( wchar_t ) );
3630
+ wnamebuf = PyMem_New ( wchar_t , len + 5 );
3631
3631
if (!wnamebuf ) {
3632
3632
PyErr_NoMemory ();
3633
3633
goto exit ;
@@ -3917,7 +3917,7 @@ posix__getfullpathname(PyObject *self, PyObject *args)
3917
3917
Py_ARRAY_LENGTH (woutbuf ),
3918
3918
woutbuf , & wtemp );
3919
3919
if (result > Py_ARRAY_LENGTH (woutbuf )) {
3920
- woutbufp = PyMem_Malloc ( result * sizeof ( wchar_t ) );
3920
+ woutbufp = PyMem_New ( wchar_t , result );
3921
3921
if (!woutbufp )
3922
3922
return PyErr_NoMemory ();
3923
3923
result = GetFullPathNameW (wpath , result , woutbufp , & wtemp );
@@ -3997,7 +3997,7 @@ posix__getfinalpathname(PyObject *self, PyObject *args)
3997
3997
if (!buf_size )
3998
3998
return win32_error_object ("GetFinalPathNameByHandle" , po );
3999
3999
4000
- target_path = (wchar_t * ) PyMem_Malloc (( buf_size + 1 ) * sizeof ( wchar_t ) );
4000
+ target_path = PyMem_New (wchar_t , buf_size + 1 );
4001
4001
if (!target_path )
4002
4002
return PyErr_NoMemory ();
4003
4003
@@ -4082,7 +4082,7 @@ posix__getvolumepathname(PyObject *self, PyObject *args)
4082
4082
return NULL ;
4083
4083
}
4084
4084
4085
- mountpath = (wchar_t * ) PyMem_Malloc ( buflen * sizeof ( wchar_t ) );
4085
+ mountpath = PyMem_New (wchar_t , buflen );
4086
4086
if (mountpath == NULL )
4087
4087
return PyErr_NoMemory ();
4088
4088
@@ -6213,9 +6213,9 @@ posix_getgrouplist(PyObject *self, PyObject *args)
6213
6213
#endif
6214
6214
6215
6215
#ifdef __APPLE__
6216
- groups = PyMem_Malloc ( ngroups * sizeof ( int ) );
6216
+ groups = PyMem_New ( int , ngroups );
6217
6217
#else
6218
- groups = PyMem_Malloc ( ngroups * sizeof ( gid_t ) );
6218
+ groups = PyMem_New ( gid_t , ngroups );
6219
6219
#endif
6220
6220
if (groups == NULL )
6221
6221
return PyErr_NoMemory ();
@@ -6293,7 +6293,7 @@ posix_getgroups(PyObject *self, PyObject *noargs)
6293
6293
/* groups will fit in existing array */
6294
6294
alt_grouplist = grouplist ;
6295
6295
} else {
6296
- alt_grouplist = PyMem_Malloc ( n * sizeof ( gid_t ) );
6296
+ alt_grouplist = PyMem_New ( gid_t , n );
6297
6297
if (alt_grouplist == NULL ) {
6298
6298
errno = EINVAL ;
6299
6299
return posix_error ();
@@ -6319,7 +6319,7 @@ posix_getgroups(PyObject *self, PyObject *noargs)
6319
6319
/* Avoid malloc(0) */
6320
6320
alt_grouplist = grouplist ;
6321
6321
} else {
6322
- alt_grouplist = PyMem_Malloc ( n * sizeof ( gid_t ) );
6322
+ alt_grouplist = PyMem_New ( gid_t , n );
6323
6323
if (alt_grouplist == NULL ) {
6324
6324
errno = EINVAL ;
6325
6325
return posix_error ();
0 commit comments