summaryrefslogtreecommitdiffstats
path: root/Modules/getpath.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-07-07 14:25:15 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-07-07 14:25:15 (GMT)
commit1a7425f67a0d141483d89ca80ca01e3cb7f6be92 (patch)
treec5c3db81a3f0b754d3c7d2cfafd8609cba58142a /Modules/getpath.c
parent51fa458d0a8fa6e9f583fc5a1c4164080093e763 (diff)
downloadcpython-1a7425f67a0d141483d89ca80ca01e3cb7f6be92.zip
cpython-1a7425f67a0d141483d89ca80ca01e3cb7f6be92.tar.gz
cpython-1a7425f67a0d141483d89ca80ca01e3cb7f6be92.tar.bz2
Issue #18203: Replace malloc() with PyMem_RawMalloc() at Python initialization
* Replace malloc() with PyMem_RawMalloc() * Replace PyMem_Malloc() with PyMem_RawMalloc() where the GIL is not held. * _Py_char2wchar() now returns a buffer allocated by PyMem_RawMalloc(), instead of PyMem_Malloc()
Diffstat (limited to 'Modules/getpath.c')
-rw-r--r--Modules/getpath.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/Modules/getpath.c b/Modules/getpath.c
index be164df..21dc854 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -343,7 +343,7 @@ search_for_prefix(wchar_t *argv0_path, wchar_t *home, wchar_t *_prefix)
if (vpath != NULL) {
wcscpy(prefix, argv0_path);
joinpath(prefix, vpath);
- PyMem_Free(vpath);
+ PyMem_RawFree(vpath);
joinpath(prefix, L"Lib");
joinpath(prefix, LANDMARK);
if (ismodule(prefix))
@@ -554,8 +554,7 @@ calculate_path(void)
}
else
progpath[0] = '\0';
- if (path_buffer != NULL)
- PyMem_Free(path_buffer);
+ PyMem_RawFree(path_buffer);
if (progpath[0] != SEP && progpath[0] != '\0')
absolutize(progpath);
wcsncpy(argv0_path, progpath, MAXPATHLEN);
@@ -597,7 +596,7 @@ calculate_path(void)
/* Use the location of the library as the progpath */
wcsncpy(argv0_path, wbuf, MAXPATHLEN);
}
- PyMem_Free(wbuf);
+ PyMem_RawFree(wbuf);
}
#endif
@@ -808,11 +807,10 @@ calculate_path(void)
else
wcsncpy(exec_prefix, _exec_prefix, MAXPATHLEN);
- PyMem_Free(_pythonpath);
- PyMem_Free(_prefix);
- PyMem_Free(_exec_prefix);
- if (rtpypath != NULL)
- PyMem_Free(rtpypath);
+ PyMem_RawFree(_pythonpath);
+ PyMem_RawFree(_prefix);
+ PyMem_RawFree(_exec_prefix);
+ PyMem_RawFree(rtpypath);
}
@@ -822,7 +820,7 @@ Py_SetPath(const wchar_t *path)
{
if (module_search_path != NULL) {
if (module_search_path_malloced)
- PyMem_Free(module_search_path);
+ PyMem_RawFree(module_search_path);
module_search_path = NULL;
module_search_path_malloced = 0;
}
@@ -831,7 +829,7 @@ Py_SetPath(const wchar_t *path)
wchar_t *prog = Py_GetProgramName();
wcsncpy(progpath, prog, MAXPATHLEN);
exec_prefix[0] = prefix[0] = L'\0';
- module_search_path = PyMem_Malloc((wcslen(path) + 1) * sizeof(wchar_t));
+ module_search_path = PyMem_RawMalloc((wcslen(path) + 1) * sizeof(wchar_t));
module_search_path_malloced = 1;
if (module_search_path != NULL)
wcscpy(module_search_path, path);