Issue #18203: Replace malloc() with PyMem_Malloc() in Python modules

Replace malloc() with PyMem_Malloc() when the GIL is held, or with
PyMem_RawMalloc() otherwise.
This commit is contained in:
Victor Stinner 2013-07-07 16:21:41 +02:00
parent 1a7425f67a
commit b64049183c
10 changed files with 52 additions and 55 deletions

View file

@ -938,7 +938,7 @@ Reg2Py(BYTE *retDataBuf, DWORD retDataSize, DWORD typ)
wchar_t *data = (wchar_t *)retDataBuf;
int len = retDataSize / 2;
int s = countStrings(data, len);
wchar_t **str = (wchar_t **)malloc(sizeof(wchar_t *)*s);
wchar_t **str = (wchar_t **)PyMem_Malloc(sizeof(wchar_t *)*s);
if (str == NULL)
return PyErr_NoMemory();
@ -959,7 +959,7 @@ Reg2Py(BYTE *retDataBuf, DWORD retDataSize, DWORD typ)
index,
PyUnicode_FromWideChar(str[index], len));
}
free(str);
PyMem_Free(str);
break;
}