diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-12-01 17:27:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-01 17:27:09 (GMT) |
commit | b64de46aae148cfab0980e0ad478da7aafc44900 (patch) | |
tree | 08df481be4201aeb0c8875c115168d4c4e055140 /Objects/obmalloc.c | |
parent | 8f5c28b19374df47ebe3d665e54c1dda5c2d7dca (diff) | |
download | cpython-b64de46aae148cfab0980e0ad478da7aafc44900.zip cpython-b64de46aae148cfab0980e0ad478da7aafc44900.tar.gz cpython-b64de46aae148cfab0980e0ad478da7aafc44900.tar.bz2 |
bpo-32030: Cleanup "path config" code (#4663)
* Rename PyPathConfig structure to _PyPathConfig and move it to
Include/internal/pystate.h
* Rename path_config to _Py_path_config
* _PyPathConfig: Rename program_name field to program_full_path
* Add assert(str != NULL); to _PyMem_RawWcsdup(), _PyMem_RawStrdup()
and _PyMem_Strdup().
* Rename calculate_path() to pathconfig_global_init(). The function
now does nothing if it's already initiallized.
Diffstat (limited to 'Objects/obmalloc.c')
-rw-r--r-- | Objects/obmalloc.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c index 4d85f0c..7911028 100644 --- a/Objects/obmalloc.c +++ b/Objects/obmalloc.c @@ -564,6 +564,8 @@ PyMem_Free(void *ptr) wchar_t* _PyMem_RawWcsdup(const wchar_t *str) { + assert(str != NULL); + size_t len = wcslen(str); if (len > (size_t)PY_SSIZE_T_MAX / sizeof(wchar_t) - 1) { return NULL; @@ -582,13 +584,12 @@ _PyMem_RawWcsdup(const wchar_t *str) char * _PyMem_RawStrdup(const char *str) { - size_t size; - char *copy; - - size = strlen(str) + 1; - copy = PyMem_RawMalloc(size); - if (copy == NULL) + assert(str != NULL); + size_t size = strlen(str) + 1; + char *copy = PyMem_RawMalloc(size); + if (copy == NULL) { return NULL; + } memcpy(copy, str, size); return copy; } @@ -596,13 +597,12 @@ _PyMem_RawStrdup(const char *str) char * _PyMem_Strdup(const char *str) { - size_t size; - char *copy; - - size = strlen(str) + 1; - copy = PyMem_Malloc(size); - if (copy == NULL) + assert(str != NULL); + size_t size = strlen(str) + 1; + char *copy = PyMem_Malloc(size); + if (copy == NULL) { return NULL; + } memcpy(copy, str, size); return copy; } |