summaryrefslogtreecommitdiff
path: root/Objects/obmalloc.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-11-24 22:55:40 +0100
committerGitHub <noreply@github.com>2017-11-24 22:55:40 +0100
commit46972b7bc385ec2bdc7f567bbd22c9e56ffdf003 (patch)
treee55f61feac1afb22e18bb33274a5e3f0beec5355 /Objects/obmalloc.c
parent84c4b1938fade2b425ac906730beabd413de094d (diff)
downloadcpython-git-46972b7bc385ec2bdc7f567bbd22c9e56ffdf003.tar.gz
bpo-32030: Add _PyMainInterpreterConfig_ReadEnv() (#4542)
Py_GetPath() and Py_Main() now call _PyMainInterpreterConfig_ReadEnv() to share the same code to get environment variables. Changes: * Add _PyMainInterpreterConfig_ReadEnv() * Add _PyMainInterpreterConfig_Clear() * Add _PyMem_RawWcsdup() * _PyMainInterpreterConfig: rename pythonhome to home * Rename _Py_ReadMainInterpreterConfig() to _PyMainInterpreterConfig_Read() * Use _Py_INIT_USER_ERR(), instead of _Py_INIT_ERR(), for decoding errors: the user is able to fix the issue, it's not a bug in Python. Same change was made in _Py_INIT_NO_MEMORY(). * Remove _Py_GetPythonHomeWithConfig()
Diffstat (limited to 'Objects/obmalloc.c')
-rw-r--r--Objects/obmalloc.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c
index 96a451ee49..9bd9798630 100644
--- a/Objects/obmalloc.c
+++ b/Objects/obmalloc.c
@@ -455,6 +455,24 @@ PyMem_Free(void *ptr)
}
+wchar_t*
+_PyMem_RawWcsdup(const wchar_t *str)
+{
+ size_t len = wcslen(str);
+ if (len > (size_t)PY_SSIZE_T_MAX / sizeof(wchar_t) - 1) {
+ return NULL;
+ }
+
+ size_t size = (len + 1) * sizeof(wchar_t);
+ wchar_t *str2 = PyMem_RawMalloc(size);
+ if (str2 == NULL) {
+ return NULL;
+ }
+
+ memcpy(str2, str, size);
+ return str2;
+}
+
char *
_PyMem_RawStrdup(const char *str)
{