diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-07-07 21:30:24 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-07-07 21:30:24 (GMT) |
commit | 49fc8ece8172162510890f42127d2aa4e13f878b (patch) | |
tree | 798c7555b232e40e607ec1b01cec87687515cf57 /Modules/_cursesmodule.c | |
parent | 6f8eeee7b9cae7e3f899c89baefe9acc575f2fb5 (diff) | |
download | cpython-49fc8ece8172162510890f42127d2aa4e13f878b.zip cpython-49fc8ece8172162510890f42127d2aa4e13f878b.tar.gz cpython-49fc8ece8172162510890f42127d2aa4e13f878b.tar.bz2 |
Issue #18203: Add _PyMem_RawStrdup() and _PyMem_Strdup()
Replace strdup() with _PyMem_RawStrdup() or _PyMem_Strdup(), depending if the
GIL is held or not.
Diffstat (limited to 'Modules/_cursesmodule.c')
-rw-r--r-- | Modules/_cursesmodule.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index fbe18f6..5d14898 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -529,7 +529,7 @@ PyCursesWindow_New(WINDOW *win, const char *encoding) wo = PyObject_NEW(PyCursesWindowObject, &PyCursesWindow_Type); if (wo == NULL) return NULL; wo->win = win; - wo->encoding = strdup(encoding); + wo->encoding = _PyMem_Strdup(encoding); if (wo->encoding == NULL) { Py_DECREF(wo); PyErr_NoMemory(); @@ -543,7 +543,7 @@ PyCursesWindow_Dealloc(PyCursesWindowObject *wo) { if (wo->win != stdscr) delwin(wo->win); if (wo->encoding != NULL) - free(wo->encoding); + PyMem_Free(wo->encoding); PyObject_DEL(wo); } @@ -1938,13 +1938,13 @@ PyCursesWindow_set_encoding(PyCursesWindowObject *self, PyObject *value) ascii = PyUnicode_AsASCIIString(value); if (ascii == NULL) return -1; - encoding = strdup(PyBytes_AS_STRING(ascii)); + encoding = _PyMem_Strdup(PyBytes_AS_STRING(ascii)); Py_DECREF(ascii); if (encoding == NULL) { PyErr_NoMemory(); return -1; } - free(self->encoding); + PyMem_Free(self->encoding); self->encoding = encoding; return 0; } |