mirror of
https://github.com/python/cpython.git
synced 2025-07-19 09:15:34 +00:00
Issue #18203: Add _PyMem_RawStrdup() and _PyMem_Strdup()
Replace strdup() with _PyMem_RawStrdup() or _PyMem_Strdup(), depending if the GIL is held or not.
This commit is contained in:
parent
6f8eeee7b9
commit
49fc8ece81
8 changed files with 64 additions and 29 deletions
|
@ -43,12 +43,12 @@ main(int argc, char **argv)
|
|||
fpsetmask(m & ~FP_X_OFL);
|
||||
#endif
|
||||
|
||||
oldloc = strdup(setlocale(LC_ALL, NULL));
|
||||
oldloc = _PyMem_RawStrdup(setlocale(LC_ALL, NULL));
|
||||
setlocale(LC_ALL, "");
|
||||
for (i = 0; i < argc; i++) {
|
||||
argv_copy[i] = _Py_char2wchar(argv[i], NULL);
|
||||
if (!argv_copy[i]) {
|
||||
free(oldloc);
|
||||
PyMem_RawFree(oldloc);
|
||||
fprintf(stderr, "Fatal Python error: "
|
||||
"unable to decode the command line argument #%i\n",
|
||||
i + 1);
|
||||
|
@ -59,7 +59,7 @@ main(int argc, char **argv)
|
|||
argv_copy2[argc] = argv_copy[argc] = NULL;
|
||||
|
||||
setlocale(LC_ALL, oldloc);
|
||||
free(oldloc);
|
||||
PyMem_RawFree(oldloc);
|
||||
res = Py_Main(argc, argv_copy);
|
||||
for (i = 0; i < argc; i++) {
|
||||
PyMem_RawFree(argv_copy2[i]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue