@@ -1638,7 +1638,7 @@ get_target_path(HANDLE hdl, wchar_t **target_path)
16381638 if (!buf_size )
16391639 return FALSE;
16401640
1641- buf = (wchar_t * ) PyMem_Malloc (( buf_size + 1 ) * sizeof ( wchar_t ) );
1641+ buf = PyMem_New (wchar_t , buf_size + 1 );
16421642 if (!buf ) {
16431643 SetLastError (ERROR_OUTOFMEMORY );
16441644 return FALSE;
@@ -3627,7 +3627,7 @@ _listdir_windows_no_opendir(path_t *path, PyObject *list)
36273627 len = wcslen (path -> wide );
36283628 }
36293629 /* 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 );
36313631 if (!wnamebuf ) {
36323632 PyErr_NoMemory ();
36333633 goto exit ;
@@ -3917,7 +3917,7 @@ posix__getfullpathname(PyObject *self, PyObject *args)
39173917 Py_ARRAY_LENGTH (woutbuf ),
39183918 woutbuf , & wtemp );
39193919 if (result > Py_ARRAY_LENGTH (woutbuf )) {
3920- woutbufp = PyMem_Malloc ( result * sizeof ( wchar_t ) );
3920+ woutbufp = PyMem_New ( wchar_t , result );
39213921 if (!woutbufp )
39223922 return PyErr_NoMemory ();
39233923 result = GetFullPathNameW (wpath , result , woutbufp , & wtemp );
@@ -3997,7 +3997,7 @@ posix__getfinalpathname(PyObject *self, PyObject *args)
39973997 if (!buf_size )
39983998 return win32_error_object ("GetFinalPathNameByHandle" , po );
39993999
4000- target_path = (wchar_t * ) PyMem_Malloc (( buf_size + 1 ) * sizeof ( wchar_t ) );
4000+ target_path = PyMem_New (wchar_t , buf_size + 1 );
40014001 if (!target_path )
40024002 return PyErr_NoMemory ();
40034003
@@ -4082,7 +4082,7 @@ posix__getvolumepathname(PyObject *self, PyObject *args)
40824082 return NULL ;
40834083 }
40844084
4085- mountpath = (wchar_t * ) PyMem_Malloc ( buflen * sizeof ( wchar_t ) );
4085+ mountpath = PyMem_New (wchar_t , buflen );
40864086 if (mountpath == NULL )
40874087 return PyErr_NoMemory ();
40884088
@@ -6213,9 +6213,9 @@ posix_getgrouplist(PyObject *self, PyObject *args)
62136213#endif
62146214
62156215#ifdef __APPLE__
6216- groups = PyMem_Malloc ( ngroups * sizeof ( int ) );
6216+ groups = PyMem_New ( int , ngroups );
62176217#else
6218- groups = PyMem_Malloc ( ngroups * sizeof ( gid_t ) );
6218+ groups = PyMem_New ( gid_t , ngroups );
62196219#endif
62206220 if (groups == NULL )
62216221 return PyErr_NoMemory ();
@@ -6293,7 +6293,7 @@ posix_getgroups(PyObject *self, PyObject *noargs)
62936293 /* groups will fit in existing array */
62946294 alt_grouplist = grouplist ;
62956295 } else {
6296- alt_grouplist = PyMem_Malloc ( n * sizeof ( gid_t ) );
6296+ alt_grouplist = PyMem_New ( gid_t , n );
62976297 if (alt_grouplist == NULL ) {
62986298 errno = EINVAL ;
62996299 return posix_error ();
@@ -6319,7 +6319,7 @@ posix_getgroups(PyObject *self, PyObject *noargs)
63196319 /* Avoid malloc(0) */
63206320 alt_grouplist = grouplist ;
63216321 } else {
6322- alt_grouplist = PyMem_Malloc ( n * sizeof ( gid_t ) );
6322+ alt_grouplist = PyMem_New ( gid_t , n );
63236323 if (alt_grouplist == NULL ) {
63246324 errno = EINVAL ;
63256325 return posix_error ();
0 commit comments