bpo-42519: Replace PyMem_MALLOC() with PyMem_Malloc() (GH-23586)
No longer use deprecated aliases to functions: * Replace PyMem_MALLOC() with PyMem_Malloc() * Replace PyMem_REALLOC() with PyMem_Realloc() * Replace PyMem_FREE() with PyMem_Free() * Replace PyMem_Del() with PyMem_Free() * Replace PyMem_DEL() with PyMem_Free() Modify also the PyMem_DEL() macro to use directly PyMem_Free().
This commit is contained in:
parent
b2d0c66e88
commit
00d7abd7ef
|
@ -102,7 +102,7 @@ PyAPI_FUNC(void *) PyObject_Realloc(void *ptr, size_t new_size);
|
||||||
PyAPI_FUNC(void) PyObject_Free(void *ptr);
|
PyAPI_FUNC(void) PyObject_Free(void *ptr);
|
||||||
|
|
||||||
|
|
||||||
/* Macros */
|
// Deprecated aliases only kept for backward compatibility.
|
||||||
#define PyObject_MALLOC PyObject_Malloc
|
#define PyObject_MALLOC PyObject_Malloc
|
||||||
#define PyObject_REALLOC PyObject_Realloc
|
#define PyObject_REALLOC PyObject_Realloc
|
||||||
#define PyObject_FREE PyObject_Free
|
#define PyObject_FREE PyObject_Free
|
||||||
|
@ -138,8 +138,8 @@ PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t);
|
||||||
#define PyObject_NewVar(type, typeobj, n) \
|
#define PyObject_NewVar(type, typeobj, n) \
|
||||||
( (type *) _PyObject_NewVar((typeobj), (n)) )
|
( (type *) _PyObject_NewVar((typeobj), (n)) )
|
||||||
|
|
||||||
// Alias to PyObject_New(). In Python 3.8, PyObject_NEW() called directly
|
// Alias to PyObject_NewVar(). In Python 3.8, PyObject_NEW_VAR() called
|
||||||
// PyObject_MALLOC() with _PyObject_VAR_SIZE().
|
// directly PyObject_MALLOC() with _PyObject_VAR_SIZE().
|
||||||
#define PyObject_NEW_VAR(type, typeobj, n) PyObject_NewVar(type, typeobj, n)
|
#define PyObject_NEW_VAR(type, typeobj, n) PyObject_NewVar(type, typeobj, n)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -53,18 +53,6 @@ PyAPI_FUNC(void *) PyMem_Malloc(size_t size);
|
||||||
PyAPI_FUNC(void *) PyMem_Realloc(void *ptr, size_t new_size);
|
PyAPI_FUNC(void *) PyMem_Realloc(void *ptr, size_t new_size);
|
||||||
PyAPI_FUNC(void) PyMem_Free(void *ptr);
|
PyAPI_FUNC(void) PyMem_Free(void *ptr);
|
||||||
|
|
||||||
/* Macros. */
|
|
||||||
|
|
||||||
/* PyMem_MALLOC(0) means malloc(1). Some systems would return NULL
|
|
||||||
for malloc(0), which would be treated as an error. Some platforms
|
|
||||||
would return a pointer with no memory behind it, which would break
|
|
||||||
pymalloc. To solve these problems, allocate an extra byte. */
|
|
||||||
/* Returns NULL to indicate error if a negative size or size larger than
|
|
||||||
Py_ssize_t can represent is supplied. Helps prevents security holes. */
|
|
||||||
#define PyMem_MALLOC(n) PyMem_Malloc(n)
|
|
||||||
#define PyMem_REALLOC(p, n) PyMem_Realloc(p, n)
|
|
||||||
#define PyMem_FREE(p) PyMem_Free(p)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Type-oriented memory interface
|
* Type-oriented memory interface
|
||||||
* ==============================
|
* ==============================
|
||||||
|
@ -78,9 +66,6 @@ PyAPI_FUNC(void) PyMem_Free(void *ptr);
|
||||||
#define PyMem_New(type, n) \
|
#define PyMem_New(type, n) \
|
||||||
( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
|
( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
|
||||||
( (type *) PyMem_Malloc((n) * sizeof(type)) ) )
|
( (type *) PyMem_Malloc((n) * sizeof(type)) ) )
|
||||||
#define PyMem_NEW(type, n) \
|
|
||||||
( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
|
|
||||||
( (type *) PyMem_MALLOC((n) * sizeof(type)) ) )
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The value of (p) is always clobbered by this macro regardless of success.
|
* The value of (p) is always clobbered by this macro regardless of success.
|
||||||
|
@ -91,15 +76,16 @@ PyAPI_FUNC(void) PyMem_Free(void *ptr);
|
||||||
#define PyMem_Resize(p, type, n) \
|
#define PyMem_Resize(p, type, n) \
|
||||||
( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
|
( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
|
||||||
(type *) PyMem_Realloc((p), (n) * sizeof(type)) )
|
(type *) PyMem_Realloc((p), (n) * sizeof(type)) )
|
||||||
#define PyMem_RESIZE(p, type, n) \
|
|
||||||
( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
|
|
||||||
(type *) PyMem_REALLOC((p), (n) * sizeof(type)) )
|
|
||||||
|
|
||||||
/* PyMem{Del,DEL} are left over from ancient days, and shouldn't be used
|
|
||||||
* anymore. They're just confusing aliases for PyMem_{Free,FREE} now.
|
// Deprecated aliases only kept for backward compatibility.
|
||||||
*/
|
#define PyMem_MALLOC(n) PyMem_Malloc(n)
|
||||||
#define PyMem_Del PyMem_Free
|
#define PyMem_NEW(type, n) PyMem_New(type, n)
|
||||||
#define PyMem_DEL PyMem_FREE
|
#define PyMem_REALLOC(p, n) PyMem_Realloc(p, n)
|
||||||
|
#define PyMem_RESIZE(p, type, n) PyMem_Resize(p, type, n)
|
||||||
|
#define PyMem_FREE(p) PyMem_Free(p)
|
||||||
|
#define PyMem_Del(p) PyMem_Free(p)
|
||||||
|
#define PyMem_DEL(p) PyMem_Free(p)
|
||||||
|
|
||||||
|
|
||||||
#ifndef Py_LIMITED_API
|
#ifndef Py_LIMITED_API
|
||||||
|
|
|
@ -370,8 +370,8 @@ _locale_strcoll_impl(PyObject *module, PyObject *os1, PyObject *os2)
|
||||||
result = PyLong_FromLong(wcscoll(ws1, ws2));
|
result = PyLong_FromLong(wcscoll(ws1, ws2));
|
||||||
done:
|
done:
|
||||||
/* Deallocate everything. */
|
/* Deallocate everything. */
|
||||||
if (ws1) PyMem_FREE(ws1);
|
if (ws1) PyMem_Free(ws1);
|
||||||
if (ws2) PyMem_FREE(ws2);
|
if (ws2) PyMem_Free(ws2);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -442,7 +442,7 @@ Pdata_dealloc(Pdata *self)
|
||||||
while (--i >= 0) {
|
while (--i >= 0) {
|
||||||
Py_DECREF(self->data[i]);
|
Py_DECREF(self->data[i]);
|
||||||
}
|
}
|
||||||
PyMem_FREE(self->data);
|
PyMem_Free(self->data);
|
||||||
PyObject_Del(self);
|
PyObject_Del(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,7 +465,7 @@ Pdata_New(void)
|
||||||
self->mark_set = 0;
|
self->mark_set = 0;
|
||||||
self->fence = 0;
|
self->fence = 0;
|
||||||
self->allocated = 8;
|
self->allocated = 8;
|
||||||
self->data = PyMem_MALLOC(self->allocated * sizeof(PyObject *));
|
self->data = PyMem_Malloc(self->allocated * sizeof(PyObject *));
|
||||||
if (self->data)
|
if (self->data)
|
||||||
return (PyObject *)self;
|
return (PyObject *)self;
|
||||||
Py_DECREF(self);
|
Py_DECREF(self);
|
||||||
|
@ -726,7 +726,7 @@ static PyTypeObject Unpickler_Type;
|
||||||
static PyMemoTable *
|
static PyMemoTable *
|
||||||
PyMemoTable_New(void)
|
PyMemoTable_New(void)
|
||||||
{
|
{
|
||||||
PyMemoTable *memo = PyMem_MALLOC(sizeof(PyMemoTable));
|
PyMemoTable *memo = PyMem_Malloc(sizeof(PyMemoTable));
|
||||||
if (memo == NULL) {
|
if (memo == NULL) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -735,9 +735,9 @@ PyMemoTable_New(void)
|
||||||
memo->mt_used = 0;
|
memo->mt_used = 0;
|
||||||
memo->mt_allocated = MT_MINSIZE;
|
memo->mt_allocated = MT_MINSIZE;
|
||||||
memo->mt_mask = MT_MINSIZE - 1;
|
memo->mt_mask = MT_MINSIZE - 1;
|
||||||
memo->mt_table = PyMem_MALLOC(MT_MINSIZE * sizeof(PyMemoEntry));
|
memo->mt_table = PyMem_Malloc(MT_MINSIZE * sizeof(PyMemoEntry));
|
||||||
if (memo->mt_table == NULL) {
|
if (memo->mt_table == NULL) {
|
||||||
PyMem_FREE(memo);
|
PyMem_Free(memo);
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -758,10 +758,10 @@ PyMemoTable_Copy(PyMemoTable *self)
|
||||||
new->mt_mask = self->mt_mask;
|
new->mt_mask = self->mt_mask;
|
||||||
/* The table we get from _New() is probably smaller than we wanted.
|
/* The table we get from _New() is probably smaller than we wanted.
|
||||||
Free it and allocate one that's the right size. */
|
Free it and allocate one that's the right size. */
|
||||||
PyMem_FREE(new->mt_table);
|
PyMem_Free(new->mt_table);
|
||||||
new->mt_table = PyMem_NEW(PyMemoEntry, self->mt_allocated);
|
new->mt_table = PyMem_NEW(PyMemoEntry, self->mt_allocated);
|
||||||
if (new->mt_table == NULL) {
|
if (new->mt_table == NULL) {
|
||||||
PyMem_FREE(new);
|
PyMem_Free(new);
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -800,8 +800,8 @@ PyMemoTable_Del(PyMemoTable *self)
|
||||||
return;
|
return;
|
||||||
PyMemoTable_Clear(self);
|
PyMemoTable_Clear(self);
|
||||||
|
|
||||||
PyMem_FREE(self->mt_table);
|
PyMem_Free(self->mt_table);
|
||||||
PyMem_FREE(self);
|
PyMem_Free(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Since entries cannot be deleted from this hashtable, _PyMemoTable_Lookup()
|
/* Since entries cannot be deleted from this hashtable, _PyMemoTable_Lookup()
|
||||||
|
@ -880,7 +880,7 @@ _PyMemoTable_ResizeTable(PyMemoTable *self, size_t min_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Deallocate the old table. */
|
/* Deallocate the old table. */
|
||||||
PyMem_FREE(oldtable);
|
PyMem_Free(oldtable);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1582,7 +1582,7 @@ _Unpickler_MemoCleanup(UnpicklerObject *self)
|
||||||
while (--i >= 0) {
|
while (--i >= 0) {
|
||||||
Py_XDECREF(memo[i]);
|
Py_XDECREF(memo[i]);
|
||||||
}
|
}
|
||||||
PyMem_FREE(memo);
|
PyMem_Free(memo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static UnpicklerObject *
|
static UnpicklerObject *
|
||||||
|
@ -7544,7 +7544,7 @@ Unpickler_set_memo(UnpicklerObject *self, PyObject *obj, void *Py_UNUSED(ignored
|
||||||
for (size_t i = new_memo_size - 1; i != SIZE_MAX; i--) {
|
for (size_t i = new_memo_size - 1; i != SIZE_MAX; i--) {
|
||||||
Py_XDECREF(new_memo[i]);
|
Py_XDECREF(new_memo[i]);
|
||||||
}
|
}
|
||||||
PyMem_FREE(new_memo);
|
PyMem_Free(new_memo);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,7 +197,7 @@ static void
|
||||||
data_stack_dealloc(SRE_STATE* state)
|
data_stack_dealloc(SRE_STATE* state)
|
||||||
{
|
{
|
||||||
if (state->data_stack) {
|
if (state->data_stack) {
|
||||||
PyMem_FREE(state->data_stack);
|
PyMem_Free(state->data_stack);
|
||||||
state->data_stack = NULL;
|
state->data_stack = NULL;
|
||||||
}
|
}
|
||||||
state->data_stack_size = state->data_stack_base = 0;
|
state->data_stack_size = state->data_stack_base = 0;
|
||||||
|
@ -213,7 +213,7 @@ data_stack_grow(SRE_STATE* state, Py_ssize_t size)
|
||||||
void* stack;
|
void* stack;
|
||||||
cursize = minsize+minsize/4+1024;
|
cursize = minsize+minsize/4+1024;
|
||||||
TRACE(("allocate/grow stack %zd\n", cursize));
|
TRACE(("allocate/grow stack %zd\n", cursize));
|
||||||
stack = PyMem_REALLOC(state->data_stack, cursize);
|
stack = PyMem_Realloc(state->data_stack, cursize);
|
||||||
if (!stack) {
|
if (!stack) {
|
||||||
data_stack_dealloc(state);
|
data_stack_dealloc(state);
|
||||||
return SRE_ERROR_MEMORY;
|
return SRE_ERROR_MEMORY;
|
||||||
|
@ -472,7 +472,7 @@ state_init(SRE_STATE* state, PatternObject* pattern, PyObject* string,
|
||||||
/* We add an explicit cast here because MSVC has a bug when
|
/* We add an explicit cast here because MSVC has a bug when
|
||||||
compiling C code where it believes that `const void**` cannot be
|
compiling C code where it believes that `const void**` cannot be
|
||||||
safely casted to `void*`, see bpo-39943 for details. */
|
safely casted to `void*`, see bpo-39943 for details. */
|
||||||
PyMem_Del((void*) state->mark);
|
PyMem_Free((void*) state->mark);
|
||||||
state->mark = NULL;
|
state->mark = NULL;
|
||||||
if (state->buffer.buf)
|
if (state->buffer.buf)
|
||||||
PyBuffer_Release(&state->buffer);
|
PyBuffer_Release(&state->buffer);
|
||||||
|
@ -487,7 +487,7 @@ state_fini(SRE_STATE* state)
|
||||||
Py_XDECREF(state->string);
|
Py_XDECREF(state->string);
|
||||||
data_stack_dealloc(state);
|
data_stack_dealloc(state);
|
||||||
/* See above PyMem_Del for why we explicitly cast here. */
|
/* See above PyMem_Del for why we explicitly cast here. */
|
||||||
PyMem_Del((void*) state->mark);
|
PyMem_Free((void*) state->mark);
|
||||||
state->mark = NULL;
|
state->mark = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3306,10 +3306,10 @@ context_dealloc(PySSLContext *self)
|
||||||
context_clear(self);
|
context_clear(self);
|
||||||
SSL_CTX_free(self->ctx);
|
SSL_CTX_free(self->ctx);
|
||||||
#if HAVE_NPN
|
#if HAVE_NPN
|
||||||
PyMem_FREE(self->npn_protocols);
|
PyMem_Free(self->npn_protocols);
|
||||||
#endif
|
#endif
|
||||||
#if HAVE_ALPN
|
#if HAVE_ALPN
|
||||||
PyMem_FREE(self->alpn_protocols);
|
PyMem_Free(self->alpn_protocols);
|
||||||
#endif
|
#endif
|
||||||
Py_TYPE(self)->tp_free(self);
|
Py_TYPE(self)->tp_free(self);
|
||||||
Py_DECREF(tp);
|
Py_DECREF(tp);
|
||||||
|
@ -3510,7 +3510,7 @@ _ssl__SSLContext__set_alpn_protocols_impl(PySSLContext *self,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyMem_FREE(self->alpn_protocols);
|
PyMem_Free(self->alpn_protocols);
|
||||||
self->alpn_protocols = PyMem_Malloc(protos->len);
|
self->alpn_protocols = PyMem_Malloc(protos->len);
|
||||||
if (!self->alpn_protocols)
|
if (!self->alpn_protocols)
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
|
|
|
@ -1373,14 +1373,14 @@ prepare_s(PyStructObject *self)
|
||||||
|
|
||||||
self->s_size = size;
|
self->s_size = size;
|
||||||
self->s_len = len;
|
self->s_len = len;
|
||||||
codes = PyMem_MALLOC((ncodes + 1) * sizeof(formatcode));
|
codes = PyMem_Malloc((ncodes + 1) * sizeof(formatcode));
|
||||||
if (codes == NULL) {
|
if (codes == NULL) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* Free any s_codes value left over from a previous initialization. */
|
/* Free any s_codes value left over from a previous initialization. */
|
||||||
if (self->s_codes != NULL)
|
if (self->s_codes != NULL)
|
||||||
PyMem_FREE(self->s_codes);
|
PyMem_Free(self->s_codes);
|
||||||
self->s_codes = codes;
|
self->s_codes = codes;
|
||||||
|
|
||||||
s = fmt;
|
s = fmt;
|
||||||
|
@ -1502,7 +1502,7 @@ s_dealloc(PyStructObject *s)
|
||||||
if (s->weakreflist != NULL)
|
if (s->weakreflist != NULL)
|
||||||
PyObject_ClearWeakRefs((PyObject *)s);
|
PyObject_ClearWeakRefs((PyObject *)s);
|
||||||
if (s->s_codes != NULL) {
|
if (s->s_codes != NULL) {
|
||||||
PyMem_FREE(s->s_codes);
|
PyMem_Free(s->s_codes);
|
||||||
}
|
}
|
||||||
Py_XDECREF(s->s_format);
|
Py_XDECREF(s->s_format);
|
||||||
freefunc free_func = PyType_GetSlot(Py_TYPE(s), Py_tp_free);
|
freefunc free_func = PyType_GetSlot(Py_TYPE(s), Py_tp_free);
|
||||||
|
|
|
@ -1988,12 +1988,12 @@ unicode_asucs4(PyObject *self, PyObject *args)
|
||||||
buffer[str_len] = 0xffffU;
|
buffer[str_len] = 0xffffU;
|
||||||
|
|
||||||
if (!PyUnicode_AsUCS4(unicode, buffer, buf_len, copy_null)) {
|
if (!PyUnicode_AsUCS4(unicode, buffer, buf_len, copy_null)) {
|
||||||
PyMem_FREE(buffer);
|
PyMem_Free(buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, buffer, buf_len);
|
result = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, buffer, buf_len);
|
||||||
PyMem_FREE(buffer);
|
PyMem_Free(buffer);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1056,7 +1056,7 @@ t_bootstrap(void *boot_raw)
|
||||||
Py_DECREF(boot->func);
|
Py_DECREF(boot->func);
|
||||||
Py_DECREF(boot->args);
|
Py_DECREF(boot->args);
|
||||||
Py_XDECREF(boot->keyw);
|
Py_XDECREF(boot->keyw);
|
||||||
PyMem_DEL(boot_raw);
|
PyMem_Free(boot_raw);
|
||||||
tstate->interp->num_threads--;
|
tstate->interp->num_threads--;
|
||||||
PyThreadState_Clear(tstate);
|
PyThreadState_Clear(tstate);
|
||||||
_PyThreadState_DeleteCurrent(tstate);
|
_PyThreadState_DeleteCurrent(tstate);
|
||||||
|
@ -1107,7 +1107,7 @@ thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)
|
||||||
boot->tstate = _PyThreadState_Prealloc(boot->interp);
|
boot->tstate = _PyThreadState_Prealloc(boot->interp);
|
||||||
boot->runtime = runtime;
|
boot->runtime = runtime;
|
||||||
if (boot->tstate == NULL) {
|
if (boot->tstate == NULL) {
|
||||||
PyMem_DEL(boot);
|
PyMem_Free(boot);
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
Py_INCREF(func);
|
Py_INCREF(func);
|
||||||
|
@ -1121,7 +1121,7 @@ thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
Py_XDECREF(keyw);
|
Py_XDECREF(keyw);
|
||||||
PyThreadState_Clear(boot->tstate);
|
PyThreadState_Clear(boot->tstate);
|
||||||
PyMem_DEL(boot);
|
PyMem_Free(boot);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return PyLong_FromUnsignedLong(ident);
|
return PyLong_FromUnsignedLong(ident);
|
||||||
|
|
|
@ -2472,7 +2472,7 @@ PythonCmdDelete(ClientData clientData)
|
||||||
ENTER_PYTHON
|
ENTER_PYTHON
|
||||||
Py_XDECREF(data->self);
|
Py_XDECREF(data->self);
|
||||||
Py_XDECREF(data->func);
|
Py_XDECREF(data->func);
|
||||||
PyMem_DEL(data);
|
PyMem_Free(data);
|
||||||
LEAVE_PYTHON
|
LEAVE_PYTHON
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2545,7 +2545,7 @@ _tkinter_tkapp_createcommand_impl(TkappObject *self, const char *name,
|
||||||
CommandEvent *ev = (CommandEvent*)attemptckalloc(sizeof(CommandEvent));
|
CommandEvent *ev = (CommandEvent*)attemptckalloc(sizeof(CommandEvent));
|
||||||
if (ev == NULL) {
|
if (ev == NULL) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
PyMem_DEL(data);
|
PyMem_Free(data);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ev->ev.proc = (Tcl_EventProc*)Tkapp_CommandProc;
|
ev->ev.proc = (Tcl_EventProc*)Tkapp_CommandProc;
|
||||||
|
@ -2568,7 +2568,7 @@ _tkinter_tkapp_createcommand_impl(TkappObject *self, const char *name,
|
||||||
}
|
}
|
||||||
if (err) {
|
if (err) {
|
||||||
PyErr_SetString(Tkinter_TclError, "can't create Tcl command");
|
PyErr_SetString(Tkinter_TclError, "can't create Tcl command");
|
||||||
PyMem_DEL(data);
|
PyMem_Free(data);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2666,7 +2666,7 @@ DeleteFHCD(int id)
|
||||||
*pp = p->next;
|
*pp = p->next;
|
||||||
Py_XDECREF(p->func);
|
Py_XDECREF(p->func);
|
||||||
Py_XDECREF(p->file);
|
Py_XDECREF(p->file);
|
||||||
PyMem_DEL(p);
|
PyMem_Free(p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pp = &p->next;
|
pp = &p->next;
|
||||||
|
|
|
@ -133,7 +133,7 @@ array_resize(arrayobject *self, Py_ssize_t newsize)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newsize == 0) {
|
if (newsize == 0) {
|
||||||
PyMem_FREE(self->ob_item);
|
PyMem_Free(self->ob_item);
|
||||||
self->ob_item = NULL;
|
self->ob_item = NULL;
|
||||||
Py_SET_SIZE(self, 0);
|
Py_SET_SIZE(self, 0);
|
||||||
self->allocated = 0;
|
self->allocated = 0;
|
||||||
|
@ -652,7 +652,7 @@ array_dealloc(arrayobject *op)
|
||||||
if (op->weakreflist != NULL)
|
if (op->weakreflist != NULL)
|
||||||
PyObject_ClearWeakRefs((PyObject *) op);
|
PyObject_ClearWeakRefs((PyObject *) op);
|
||||||
if (op->ob_item != NULL)
|
if (op->ob_item != NULL)
|
||||||
PyMem_DEL(op->ob_item);
|
PyMem_Free(op->ob_item);
|
||||||
Py_TYPE(op)->tp_free((PyObject *)op);
|
Py_TYPE(op)->tp_free((PyObject *)op);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1191,13 +1191,13 @@ _multibytecodec_MultibyteIncrementalDecoder_decode_impl(MultibyteIncrementalDeco
|
||||||
goto errorexit;
|
goto errorexit;
|
||||||
|
|
||||||
if (wdata != data)
|
if (wdata != data)
|
||||||
PyMem_Del(wdata);
|
PyMem_Free(wdata);
|
||||||
Py_XDECREF(buf.excobj);
|
Py_XDECREF(buf.excobj);
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
errorexit:
|
errorexit:
|
||||||
if (wdata != NULL && wdata != data)
|
if (wdata != NULL && wdata != data)
|
||||||
PyMem_Del(wdata);
|
PyMem_Free(wdata);
|
||||||
Py_XDECREF(buf.excobj);
|
Py_XDECREF(buf.excobj);
|
||||||
_PyUnicodeWriter_Dealloc(&buf.writer);
|
_PyUnicodeWriter_Dealloc(&buf.writer);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -5480,7 +5480,7 @@ free_string_array(EXECV_CHAR **array, Py_ssize_t count)
|
||||||
Py_ssize_t i;
|
Py_ssize_t i;
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
PyMem_Free(array[i]);
|
PyMem_Free(array[i]);
|
||||||
PyMem_DEL(array);
|
PyMem_Free(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -6510,9 +6510,10 @@ os_spawnve_impl(PyObject *module, int mode, path_t *path, PyObject *argv,
|
||||||
res = Py_BuildValue(_Py_PARSE_INTPTR, spawnval);
|
res = Py_BuildValue(_Py_PARSE_INTPTR, spawnval);
|
||||||
|
|
||||||
fail_2:
|
fail_2:
|
||||||
while (--envc >= 0)
|
while (--envc >= 0) {
|
||||||
PyMem_DEL(envlist[envc]);
|
PyMem_Free(envlist[envc]);
|
||||||
PyMem_DEL(envlist);
|
}
|
||||||
|
PyMem_Free(envlist);
|
||||||
fail_1:
|
fail_1:
|
||||||
free_string_array(argvlist, lastarg);
|
free_string_array(argvlist, lastarg);
|
||||||
fail_0:
|
fail_0:
|
||||||
|
@ -7444,7 +7445,7 @@ os_getgrouplist_impl(PyObject *module, const char *user, gid_t basegid)
|
||||||
|
|
||||||
list = PyList_New(ngroups);
|
list = PyList_New(ngroups);
|
||||||
if (list == NULL) {
|
if (list == NULL) {
|
||||||
PyMem_Del(groups);
|
PyMem_Free(groups);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7456,13 +7457,13 @@ os_getgrouplist_impl(PyObject *module, const char *user, gid_t basegid)
|
||||||
#endif
|
#endif
|
||||||
if (o == NULL) {
|
if (o == NULL) {
|
||||||
Py_DECREF(list);
|
Py_DECREF(list);
|
||||||
PyMem_Del(groups);
|
PyMem_Free(groups);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
PyList_SET_ITEM(list, i, o);
|
PyList_SET_ITEM(list, i, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyMem_Del(groups);
|
PyMem_Free(groups);
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@ -9407,7 +9408,7 @@ iov_setup(struct iovec **iov, Py_buffer **buf, PyObject *seq, Py_ssize_t cnt, in
|
||||||
|
|
||||||
*buf = PyMem_New(Py_buffer, cnt);
|
*buf = PyMem_New(Py_buffer, cnt);
|
||||||
if (*buf == NULL) {
|
if (*buf == NULL) {
|
||||||
PyMem_Del(*iov);
|
PyMem_Free(*iov);
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -9427,11 +9428,11 @@ iov_setup(struct iovec **iov, Py_buffer **buf, PyObject *seq, Py_ssize_t cnt, in
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
PyMem_Del(*iov);
|
PyMem_Free(*iov);
|
||||||
for (j = 0; j < i; j++) {
|
for (j = 0; j < i; j++) {
|
||||||
PyBuffer_Release(&(*buf)[j]);
|
PyBuffer_Release(&(*buf)[j]);
|
||||||
}
|
}
|
||||||
PyMem_Del(*buf);
|
PyMem_Free(*buf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9439,11 +9440,11 @@ static void
|
||||||
iov_cleanup(struct iovec *iov, Py_buffer *buf, int cnt)
|
iov_cleanup(struct iovec *iov, Py_buffer *buf, int cnt)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
PyMem_Del(iov);
|
PyMem_Free(iov);
|
||||||
for (i = 0; i < cnt; i++) {
|
for (i = 0; i < cnt; i++) {
|
||||||
PyBuffer_Release(&buf[i]);
|
PyBuffer_Release(&buf[i]);
|
||||||
}
|
}
|
||||||
PyMem_Del(buf);
|
PyMem_Free(buf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -12815,7 +12816,7 @@ os_listxattr_impl(PyObject *module, path_t *path, int follow_symlinks)
|
||||||
path_error(path);
|
path_error(path);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
buffer = PyMem_MALLOC(buffer_size);
|
buffer = PyMem_Malloc(buffer_size);
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
break;
|
break;
|
||||||
|
@ -12832,7 +12833,7 @@ os_listxattr_impl(PyObject *module, path_t *path, int follow_symlinks)
|
||||||
|
|
||||||
if (length < 0) {
|
if (length < 0) {
|
||||||
if (errno == ERANGE) {
|
if (errno == ERANGE) {
|
||||||
PyMem_FREE(buffer);
|
PyMem_Free(buffer);
|
||||||
buffer = NULL;
|
buffer = NULL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -12870,7 +12871,7 @@ os_listxattr_impl(PyObject *module, path_t *path, int follow_symlinks)
|
||||||
}
|
}
|
||||||
exit:
|
exit:
|
||||||
if (buffer)
|
if (buffer)
|
||||||
PyMem_FREE(buffer);
|
PyMem_Free(buffer);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif /* USE_XATTRS */
|
#endif /* USE_XATTRS */
|
||||||
|
|
|
@ -294,9 +294,9 @@ select_select_impl(PyObject *module, PyObject *rlist, PyObject *wlist,
|
||||||
wfd2obj = PyMem_NEW(pylist, FD_SETSIZE + 1);
|
wfd2obj = PyMem_NEW(pylist, FD_SETSIZE + 1);
|
||||||
efd2obj = PyMem_NEW(pylist, FD_SETSIZE + 1);
|
efd2obj = PyMem_NEW(pylist, FD_SETSIZE + 1);
|
||||||
if (rfd2obj == NULL || wfd2obj == NULL || efd2obj == NULL) {
|
if (rfd2obj == NULL || wfd2obj == NULL || efd2obj == NULL) {
|
||||||
if (rfd2obj) PyMem_DEL(rfd2obj);
|
if (rfd2obj) PyMem_Free(rfd2obj);
|
||||||
if (wfd2obj) PyMem_DEL(wfd2obj);
|
if (wfd2obj) PyMem_Free(wfd2obj);
|
||||||
if (efd2obj) PyMem_DEL(efd2obj);
|
if (efd2obj) PyMem_Free(efd2obj);
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
#endif /* SELECT_USES_HEAP */
|
#endif /* SELECT_USES_HEAP */
|
||||||
|
@ -381,9 +381,9 @@ select_select_impl(PyObject *module, PyObject *rlist, PyObject *wlist,
|
||||||
reap_obj(wfd2obj);
|
reap_obj(wfd2obj);
|
||||||
reap_obj(efd2obj);
|
reap_obj(efd2obj);
|
||||||
#ifdef SELECT_USES_HEAP
|
#ifdef SELECT_USES_HEAP
|
||||||
PyMem_DEL(rfd2obj);
|
PyMem_Free(rfd2obj);
|
||||||
PyMem_DEL(wfd2obj);
|
PyMem_Free(wfd2obj);
|
||||||
PyMem_DEL(efd2obj);
|
PyMem_Free(efd2obj);
|
||||||
#endif /* SELECT_USES_HEAP */
|
#endif /* SELECT_USES_HEAP */
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -740,7 +740,7 @@ poll_dealloc(pollObject *self)
|
||||||
{
|
{
|
||||||
PyObject* type = (PyObject *)Py_TYPE(self);
|
PyObject* type = (PyObject *)Py_TYPE(self);
|
||||||
if (self->ufds != NULL)
|
if (self->ufds != NULL)
|
||||||
PyMem_DEL(self->ufds);
|
PyMem_Free(self->ufds);
|
||||||
Py_XDECREF(self->dict);
|
Py_XDECREF(self->dict);
|
||||||
PyObject_Del(self);
|
PyObject_Del(self);
|
||||||
Py_DECREF(type);
|
Py_DECREF(type);
|
||||||
|
@ -1106,7 +1106,7 @@ newDevPollObject(PyObject *module)
|
||||||
self = PyObject_New(devpollObject, get_select_state(module)->devpoll_Type);
|
self = PyObject_New(devpollObject, get_select_state(module)->devpoll_Type);
|
||||||
if (self == NULL) {
|
if (self == NULL) {
|
||||||
close(fd_devpoll);
|
close(fd_devpoll);
|
||||||
PyMem_DEL(fds);
|
PyMem_Free(fds);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
self->fd_devpoll = fd_devpoll;
|
self->fd_devpoll = fd_devpoll;
|
||||||
|
@ -1129,7 +1129,7 @@ devpoll_dealloc(devpollObject *self)
|
||||||
{
|
{
|
||||||
PyObject *type = (PyObject *)Py_TYPE(self);
|
PyObject *type = (PyObject *)Py_TYPE(self);
|
||||||
(void)devpoll_internal_close(self);
|
(void)devpoll_internal_close(self);
|
||||||
PyMem_DEL(self->fds);
|
PyMem_Free(self->fds);
|
||||||
PyObject_Del(self);
|
PyObject_Del(self);
|
||||||
Py_DECREF(type);
|
Py_DECREF(type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,7 +198,7 @@ PyCapsule_Import(const char *name, int no_block)
|
||||||
void *return_value = NULL;
|
void *return_value = NULL;
|
||||||
char *trace;
|
char *trace;
|
||||||
size_t name_length = (strlen(name) + 1) * sizeof(char);
|
size_t name_length = (strlen(name) + 1) * sizeof(char);
|
||||||
char *name_dup = (char *)PyMem_MALLOC(name_length);
|
char *name_dup = (char *)PyMem_Malloc(name_length);
|
||||||
|
|
||||||
if (!name_dup) {
|
if (!name_dup) {
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
|
@ -247,7 +247,7 @@ PyCapsule_Import(const char *name, int no_block)
|
||||||
EXIT:
|
EXIT:
|
||||||
Py_XDECREF(object);
|
Py_XDECREF(object);
|
||||||
if (name_dup) {
|
if (name_dup) {
|
||||||
PyMem_FREE(name_dup);
|
PyMem_Free(name_dup);
|
||||||
}
|
}
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,7 +213,7 @@ PyCode_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount,
|
||||||
PyObject *arg = PyTuple_GET_ITEM(varnames, j);
|
PyObject *arg = PyTuple_GET_ITEM(varnames, j);
|
||||||
int cmp = PyUnicode_Compare(cell, arg);
|
int cmp = PyUnicode_Compare(cell, arg);
|
||||||
if (cmp == -1 && PyErr_Occurred()) {
|
if (cmp == -1 && PyErr_Occurred()) {
|
||||||
PyMem_FREE(cell2arg);
|
PyMem_Free(cell2arg);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (cmp == 0) {
|
if (cmp == 0) {
|
||||||
|
@ -224,14 +224,14 @@ PyCode_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!used_cell2arg) {
|
if (!used_cell2arg) {
|
||||||
PyMem_FREE(cell2arg);
|
PyMem_Free(cell2arg);
|
||||||
cell2arg = NULL;
|
cell2arg = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
co = PyObject_New(PyCodeObject, &PyCode_Type);
|
co = PyObject_New(PyCodeObject, &PyCode_Type);
|
||||||
if (co == NULL) {
|
if (co == NULL) {
|
||||||
if (cell2arg)
|
if (cell2arg)
|
||||||
PyMem_FREE(cell2arg);
|
PyMem_Free(cell2arg);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
co->co_argcount = argcount;
|
co->co_argcount = argcount;
|
||||||
|
@ -314,12 +314,12 @@ _PyCode_InitOpcache(PyCodeObject *co)
|
||||||
if (opts) {
|
if (opts) {
|
||||||
co->co_opcache = (_PyOpcache *)PyMem_Calloc(opts, sizeof(_PyOpcache));
|
co->co_opcache = (_PyOpcache *)PyMem_Calloc(opts, sizeof(_PyOpcache));
|
||||||
if (co->co_opcache == NULL) {
|
if (co->co_opcache == NULL) {
|
||||||
PyMem_FREE(co->co_opcache_map);
|
PyMem_Free(co->co_opcache_map);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PyMem_FREE(co->co_opcache_map);
|
PyMem_Free(co->co_opcache_map);
|
||||||
co->co_opcache_map = NULL;
|
co->co_opcache_map = NULL;
|
||||||
co->co_opcache = NULL;
|
co->co_opcache = NULL;
|
||||||
}
|
}
|
||||||
|
@ -631,10 +631,10 @@ static void
|
||||||
code_dealloc(PyCodeObject *co)
|
code_dealloc(PyCodeObject *co)
|
||||||
{
|
{
|
||||||
if (co->co_opcache != NULL) {
|
if (co->co_opcache != NULL) {
|
||||||
PyMem_FREE(co->co_opcache);
|
PyMem_Free(co->co_opcache);
|
||||||
}
|
}
|
||||||
if (co->co_opcache_map != NULL) {
|
if (co->co_opcache_map != NULL) {
|
||||||
PyMem_FREE(co->co_opcache_map);
|
PyMem_Free(co->co_opcache_map);
|
||||||
}
|
}
|
||||||
co->co_opcache_flag = 0;
|
co->co_opcache_flag = 0;
|
||||||
co->co_opcache_size = 0;
|
co->co_opcache_size = 0;
|
||||||
|
@ -664,7 +664,7 @@ code_dealloc(PyCodeObject *co)
|
||||||
Py_XDECREF(co->co_name);
|
Py_XDECREF(co->co_name);
|
||||||
Py_XDECREF(co->co_linetable);
|
Py_XDECREF(co->co_linetable);
|
||||||
if (co->co_cell2arg != NULL)
|
if (co->co_cell2arg != NULL)
|
||||||
PyMem_FREE(co->co_cell2arg);
|
PyMem_Free(co->co_cell2arg);
|
||||||
if (co->co_zombieframe != NULL)
|
if (co->co_zombieframe != NULL)
|
||||||
PyObject_GC_Del(co->co_zombieframe);
|
PyObject_GC_Del(co->co_zombieframe);
|
||||||
if (co->co_weakreflist != NULL)
|
if (co->co_weakreflist != NULL)
|
||||||
|
|
|
@ -640,7 +640,7 @@ free_keys_object(PyDictKeysObject *keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define new_values(size) PyMem_NEW(PyObject *, size)
|
#define new_values(size) PyMem_NEW(PyObject *, size)
|
||||||
#define free_values(values) PyMem_FREE(values)
|
#define free_values(values) PyMem_Free(values)
|
||||||
|
|
||||||
/* Consumes a reference to the keys object */
|
/* Consumes a reference to the keys object */
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
|
|
@ -341,7 +341,7 @@ list_dealloc(PyListObject *op)
|
||||||
while (--i >= 0) {
|
while (--i >= 0) {
|
||||||
Py_XDECREF(op->ob_item[i]);
|
Py_XDECREF(op->ob_item[i]);
|
||||||
}
|
}
|
||||||
PyMem_FREE(op->ob_item);
|
PyMem_Free(op->ob_item);
|
||||||
}
|
}
|
||||||
struct _Py_list_state *state = get_list_state();
|
struct _Py_list_state *state = get_list_state();
|
||||||
#ifdef Py_DEBUG
|
#ifdef Py_DEBUG
|
||||||
|
@ -592,7 +592,7 @@ _list_clear(PyListObject *a)
|
||||||
while (--i >= 0) {
|
while (--i >= 0) {
|
||||||
Py_XDECREF(item[i]);
|
Py_XDECREF(item[i]);
|
||||||
}
|
}
|
||||||
PyMem_FREE(item);
|
PyMem_Free(item);
|
||||||
}
|
}
|
||||||
/* Never fails; the return value can be ignored.
|
/* Never fails; the return value can be ignored.
|
||||||
Note that there is no guarantee that the list is actually empty
|
Note that there is no guarantee that the list is actually empty
|
||||||
|
@ -668,7 +668,7 @@ list_ass_slice(PyListObject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
|
||||||
/* If norig == 0, item might be NULL, in which case we may not memcpy from it. */
|
/* If norig == 0, item might be NULL, in which case we may not memcpy from it. */
|
||||||
if (s) {
|
if (s) {
|
||||||
if (s > sizeof(recycle_on_stack)) {
|
if (s > sizeof(recycle_on_stack)) {
|
||||||
recycle = (PyObject **)PyMem_MALLOC(s);
|
recycle = (PyObject **)PyMem_Malloc(s);
|
||||||
if (recycle == NULL) {
|
if (recycle == NULL) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
goto Error;
|
goto Error;
|
||||||
|
@ -706,7 +706,7 @@ list_ass_slice(PyListObject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
|
||||||
result = 0;
|
result = 0;
|
||||||
Error:
|
Error:
|
||||||
if (recycle != recycle_on_stack)
|
if (recycle != recycle_on_stack)
|
||||||
PyMem_FREE(recycle);
|
PyMem_Free(recycle);
|
||||||
Py_XDECREF(v_as_SF);
|
Py_XDECREF(v_as_SF);
|
||||||
return result;
|
return result;
|
||||||
#undef b
|
#undef b
|
||||||
|
@ -2230,7 +2230,7 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse)
|
||||||
/* Leverage stack space we allocated but won't otherwise use */
|
/* Leverage stack space we allocated but won't otherwise use */
|
||||||
keys = &ms.temparray[saved_ob_size+1];
|
keys = &ms.temparray[saved_ob_size+1];
|
||||||
else {
|
else {
|
||||||
keys = PyMem_MALLOC(sizeof(PyObject *) * saved_ob_size);
|
keys = PyMem_Malloc(sizeof(PyObject *) * saved_ob_size);
|
||||||
if (keys == NULL) {
|
if (keys == NULL) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
goto keyfunc_fail;
|
goto keyfunc_fail;
|
||||||
|
@ -2243,7 +2243,7 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse)
|
||||||
for (i=i-1 ; i>=0 ; i--)
|
for (i=i-1 ; i>=0 ; i--)
|
||||||
Py_DECREF(keys[i]);
|
Py_DECREF(keys[i]);
|
||||||
if (saved_ob_size >= MERGESTATE_TEMP_SIZE/2)
|
if (saved_ob_size >= MERGESTATE_TEMP_SIZE/2)
|
||||||
PyMem_FREE(keys);
|
PyMem_Free(keys);
|
||||||
goto keyfunc_fail;
|
goto keyfunc_fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2414,7 +2414,7 @@ fail:
|
||||||
for (i = 0; i < saved_ob_size; i++)
|
for (i = 0; i < saved_ob_size; i++)
|
||||||
Py_DECREF(keys[i]);
|
Py_DECREF(keys[i]);
|
||||||
if (saved_ob_size >= MERGESTATE_TEMP_SIZE/2)
|
if (saved_ob_size >= MERGESTATE_TEMP_SIZE/2)
|
||||||
PyMem_FREE(keys);
|
PyMem_Free(keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->allocated != -1 && result != NULL) {
|
if (self->allocated != -1 && result != NULL) {
|
||||||
|
@ -2442,7 +2442,7 @@ keyfunc_fail:
|
||||||
while (--i >= 0) {
|
while (--i >= 0) {
|
||||||
Py_XDECREF(final_ob_item[i]);
|
Py_XDECREF(final_ob_item[i]);
|
||||||
}
|
}
|
||||||
PyMem_FREE(final_ob_item);
|
PyMem_Free(final_ob_item);
|
||||||
}
|
}
|
||||||
Py_XINCREF(result);
|
Py_XINCREF(result);
|
||||||
return result;
|
return result;
|
||||||
|
@ -2908,7 +2908,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
|
||||||
}
|
}
|
||||||
|
|
||||||
garbage = (PyObject**)
|
garbage = (PyObject**)
|
||||||
PyMem_MALLOC(slicelength*sizeof(PyObject*));
|
PyMem_Malloc(slicelength*sizeof(PyObject*));
|
||||||
if (!garbage) {
|
if (!garbage) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -2949,7 +2949,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
|
||||||
for (i = 0; i < slicelength; i++) {
|
for (i = 0; i < slicelength; i++) {
|
||||||
Py_DECREF(garbage[i]);
|
Py_DECREF(garbage[i]);
|
||||||
}
|
}
|
||||||
PyMem_FREE(garbage);
|
PyMem_Free(garbage);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -2990,7 +2990,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
|
||||||
}
|
}
|
||||||
|
|
||||||
garbage = (PyObject**)
|
garbage = (PyObject**)
|
||||||
PyMem_MALLOC(slicelength*sizeof(PyObject*));
|
PyMem_Malloc(slicelength*sizeof(PyObject*));
|
||||||
if (!garbage) {
|
if (!garbage) {
|
||||||
Py_DECREF(seq);
|
Py_DECREF(seq);
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
|
@ -3011,7 +3011,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
|
||||||
Py_DECREF(garbage[i]);
|
Py_DECREF(garbage[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyMem_FREE(garbage);
|
PyMem_Free(garbage);
|
||||||
Py_DECREF(seq);
|
Py_DECREF(seq);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -211,7 +211,7 @@ _PyModule_CreateInitialized(struct PyModuleDef* module, int module_api_version)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (module->m_size > 0) {
|
if (module->m_size > 0) {
|
||||||
m->md_state = PyMem_MALLOC(module->m_size);
|
m->md_state = PyMem_Malloc(module->m_size);
|
||||||
if (!m->md_state) {
|
if (!m->md_state) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
Py_DECREF(m);
|
Py_DECREF(m);
|
||||||
|
@ -377,7 +377,7 @@ PyModule_ExecDef(PyObject *module, PyModuleDef *def)
|
||||||
if (md->md_state == NULL) {
|
if (md->md_state == NULL) {
|
||||||
/* Always set a state pointer; this serves as a marker to skip
|
/* Always set a state pointer; this serves as a marker to skip
|
||||||
* multiple initialization (importlib.reload() is no-op) */
|
* multiple initialization (importlib.reload() is no-op) */
|
||||||
md->md_state = PyMem_MALLOC(def->m_size);
|
md->md_state = PyMem_Malloc(def->m_size);
|
||||||
if (!md->md_state) {
|
if (!md->md_state) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -681,7 +681,7 @@ module_dealloc(PyModuleObject *m)
|
||||||
Py_XDECREF(m->md_dict);
|
Py_XDECREF(m->md_dict);
|
||||||
Py_XDECREF(m->md_name);
|
Py_XDECREF(m->md_name);
|
||||||
if (m->md_state != NULL)
|
if (m->md_state != NULL)
|
||||||
PyMem_FREE(m->md_state);
|
PyMem_Free(m->md_state);
|
||||||
Py_TYPE(m)->tp_free((PyObject *)m);
|
Py_TYPE(m)->tp_free((PyObject *)m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -567,14 +567,14 @@ _odict_resize(PyODictObject *od)
|
||||||
i = _odict_get_index_raw(od, _odictnode_KEY(node),
|
i = _odict_get_index_raw(od, _odictnode_KEY(node),
|
||||||
_odictnode_HASH(node));
|
_odictnode_HASH(node));
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
PyMem_FREE(fast_nodes);
|
PyMem_Free(fast_nodes);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fast_nodes[i] = node;
|
fast_nodes[i] = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Replace the old fast nodes table. */
|
/* Replace the old fast nodes table. */
|
||||||
PyMem_FREE(od->od_fast_nodes);
|
PyMem_Free(od->od_fast_nodes);
|
||||||
od->od_fast_nodes = fast_nodes;
|
od->od_fast_nodes = fast_nodes;
|
||||||
od->od_fast_nodes_size = size;
|
od->od_fast_nodes_size = size;
|
||||||
od->od_resize_sentinel = ((PyDictObject *)od)->ma_keys;
|
od->od_resize_sentinel = ((PyDictObject *)od)->ma_keys;
|
||||||
|
@ -683,7 +683,7 @@ _odict_add_new_node(PyODictObject *od, PyObject *key, Py_hash_t hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* must not be added yet */
|
/* must not be added yet */
|
||||||
node = (_ODictNode *)PyMem_MALLOC(sizeof(_ODictNode));
|
node = (_ODictNode *)PyMem_Malloc(sizeof(_ODictNode));
|
||||||
if (node == NULL) {
|
if (node == NULL) {
|
||||||
Py_DECREF(key);
|
Py_DECREF(key);
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
|
@ -701,7 +701,7 @@ _odict_add_new_node(PyODictObject *od, PyObject *key, Py_hash_t hash)
|
||||||
#define _odictnode_DEALLOC(node) \
|
#define _odictnode_DEALLOC(node) \
|
||||||
do { \
|
do { \
|
||||||
Py_DECREF(_odictnode_KEY(node)); \
|
Py_DECREF(_odictnode_KEY(node)); \
|
||||||
PyMem_FREE((void *)node); \
|
PyMem_Free((void *)node); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* Repeated calls on the same node are no-ops. */
|
/* Repeated calls on the same node are no-ops. */
|
||||||
|
@ -776,7 +776,7 @@ _odict_clear_nodes(PyODictObject *od)
|
||||||
{
|
{
|
||||||
_ODictNode *node, *next;
|
_ODictNode *node, *next;
|
||||||
|
|
||||||
PyMem_FREE(od->od_fast_nodes);
|
PyMem_Free(od->od_fast_nodes);
|
||||||
od->od_fast_nodes = NULL;
|
od->od_fast_nodes = NULL;
|
||||||
od->od_fast_nodes_size = 0;
|
od->od_fast_nodes_size = 0;
|
||||||
od->od_resize_sentinel = NULL;
|
od->od_resize_sentinel = NULL;
|
||||||
|
|
|
@ -289,7 +289,7 @@ set_table_resize(PySetObject *so, Py_ssize_t minused)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_oldtable_malloced)
|
if (is_oldtable_malloced)
|
||||||
PyMem_DEL(oldtable);
|
PyMem_Free(oldtable);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,7 +424,7 @@ set_clear_internal(PySetObject *so)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (table_is_malloced)
|
if (table_is_malloced)
|
||||||
PyMem_DEL(table);
|
PyMem_Free(table);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,7 +484,7 @@ set_dealloc(PySetObject *so)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (so->table != so->smalltable)
|
if (so->table != so->smalltable)
|
||||||
PyMem_DEL(so->table);
|
PyMem_Free(so->table);
|
||||||
Py_TYPE(so)->tp_free(so);
|
Py_TYPE(so)->tp_free(so);
|
||||||
Py_TRASHCAN_END
|
Py_TRASHCAN_END
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ done:
|
||||||
for (i = 0; i < nbufs; i++)
|
for (i = 0; i < nbufs; i++)
|
||||||
PyBuffer_Release(&buffers[i]);
|
PyBuffer_Release(&buffers[i]);
|
||||||
if (buffers != static_buffers)
|
if (buffers != static_buffers)
|
||||||
PyMem_FREE(buffers);
|
PyMem_Free(buffers);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -467,14 +467,14 @@ PyStructSequence_InitType2(PyTypeObject *type, PyStructSequence_Desc *desc)
|
||||||
type->tp_members = members;
|
type->tp_members = members;
|
||||||
|
|
||||||
if (PyType_Ready(type) < 0) {
|
if (PyType_Ready(type) < 0) {
|
||||||
PyMem_FREE(members);
|
PyMem_Free(members);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
Py_INCREF(type);
|
Py_INCREF(type);
|
||||||
|
|
||||||
if (initialize_structseq_dict(
|
if (initialize_structseq_dict(
|
||||||
desc, type->tp_dict, n_members, n_unnamed_members) < 0) {
|
desc, type->tp_dict, n_members, n_unnamed_members) < 0) {
|
||||||
PyMem_FREE(members);
|
PyMem_Free(members);
|
||||||
Py_DECREF(type);
|
Py_DECREF(type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -526,7 +526,7 @@ PyStructSequence_NewType(PyStructSequence_Desc *desc)
|
||||||
spec.slots = slots;
|
spec.slots = slots;
|
||||||
|
|
||||||
type = (PyTypeObject *)PyType_FromSpecWithBases(&spec, (PyObject *)&PyTuple_Type);
|
type = (PyTypeObject *)PyType_FromSpecWithBases(&spec, (PyObject *)&PyTuple_Type);
|
||||||
PyMem_FREE(members);
|
PyMem_Free(members);
|
||||||
if (type == NULL) {
|
if (type == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1779,7 +1779,7 @@ pmerge(PyObject *acc, PyObject **to_merge, Py_ssize_t to_merge_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
PyMem_Del(remain);
|
PyMem_Free(remain);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -1859,7 +1859,7 @@ mro_implementation(PyTypeObject *type)
|
||||||
|
|
||||||
result = PyList_New(1);
|
result = PyList_New(1);
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
PyMem_Del(to_merge);
|
PyMem_Free(to_merge);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1869,7 +1869,7 @@ mro_implementation(PyTypeObject *type)
|
||||||
Py_CLEAR(result);
|
Py_CLEAR(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyMem_Del(to_merge);
|
PyMem_Free(to_merge);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3298,7 +3298,7 @@ PyUnicode_AsWideCharString(PyObject *unicode,
|
||||||
*size = buflen;
|
*size = buflen;
|
||||||
}
|
}
|
||||||
else if (wcslen(buffer) != (size_t)buflen) {
|
else if (wcslen(buffer) != (size_t)buflen) {
|
||||||
PyMem_FREE(buffer);
|
PyMem_Free(buffer);
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"embedded null character");
|
"embedded null character");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -10211,7 +10211,7 @@ case_operation(PyObject *self,
|
||||||
PyErr_SetString(PyExc_OverflowError, "string is too long");
|
PyErr_SetString(PyExc_OverflowError, "string is too long");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
tmp = PyMem_MALLOC(sizeof(Py_UCS4) * 3 * length);
|
tmp = PyMem_Malloc(sizeof(Py_UCS4) * 3 * length);
|
||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
newlength = perform(kind, data, length, tmp, &maxchar);
|
newlength = perform(kind, data, length, tmp, &maxchar);
|
||||||
|
@ -10235,7 +10235,7 @@ case_operation(PyObject *self,
|
||||||
Py_UNREACHABLE();
|
Py_UNREACHABLE();
|
||||||
}
|
}
|
||||||
leave:
|
leave:
|
||||||
PyMem_FREE(tmp);
|
PyMem_Free(tmp);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11050,11 +11050,11 @@ replace(PyObject *self, PyObject *str1,
|
||||||
assert(release1 == (buf1 != PyUnicode_DATA(str1)));
|
assert(release1 == (buf1 != PyUnicode_DATA(str1)));
|
||||||
assert(release2 == (buf2 != PyUnicode_DATA(str2)));
|
assert(release2 == (buf2 != PyUnicode_DATA(str2)));
|
||||||
if (srelease)
|
if (srelease)
|
||||||
PyMem_FREE((void *)sbuf);
|
PyMem_Free((void *)sbuf);
|
||||||
if (release1)
|
if (release1)
|
||||||
PyMem_FREE((void *)buf1);
|
PyMem_Free((void *)buf1);
|
||||||
if (release2)
|
if (release2)
|
||||||
PyMem_FREE((void *)buf2);
|
PyMem_Free((void *)buf2);
|
||||||
assert(_PyUnicode_CheckConsistency(u, 1));
|
assert(_PyUnicode_CheckConsistency(u, 1));
|
||||||
return u;
|
return u;
|
||||||
|
|
||||||
|
@ -11064,11 +11064,11 @@ replace(PyObject *self, PyObject *str1,
|
||||||
assert(release1 == (buf1 != PyUnicode_DATA(str1)));
|
assert(release1 == (buf1 != PyUnicode_DATA(str1)));
|
||||||
assert(release2 == (buf2 != PyUnicode_DATA(str2)));
|
assert(release2 == (buf2 != PyUnicode_DATA(str2)));
|
||||||
if (srelease)
|
if (srelease)
|
||||||
PyMem_FREE((void *)sbuf);
|
PyMem_Free((void *)sbuf);
|
||||||
if (release1)
|
if (release1)
|
||||||
PyMem_FREE((void *)buf1);
|
PyMem_Free((void *)buf1);
|
||||||
if (release2)
|
if (release2)
|
||||||
PyMem_FREE((void *)buf2);
|
PyMem_Free((void *)buf2);
|
||||||
return unicode_result_unchanged(self);
|
return unicode_result_unchanged(self);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
@ -11076,11 +11076,11 @@ replace(PyObject *self, PyObject *str1,
|
||||||
assert(release1 == (buf1 != PyUnicode_DATA(str1)));
|
assert(release1 == (buf1 != PyUnicode_DATA(str1)));
|
||||||
assert(release2 == (buf2 != PyUnicode_DATA(str2)));
|
assert(release2 == (buf2 != PyUnicode_DATA(str2)));
|
||||||
if (srelease)
|
if (srelease)
|
||||||
PyMem_FREE((void *)sbuf);
|
PyMem_Free((void *)sbuf);
|
||||||
if (release1)
|
if (release1)
|
||||||
PyMem_FREE((void *)buf1);
|
PyMem_Free((void *)buf1);
|
||||||
if (release2)
|
if (release2)
|
||||||
PyMem_FREE((void *)buf2);
|
PyMem_Free((void *)buf2);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1818,7 +1818,7 @@ winreg_SetValueEx_impl(PyObject *module, HKEY key,
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
rc = RegSetValueExW(key, value_name, 0, type, data, len);
|
rc = RegSetValueExW(key, value_name, 0, type, data, len);
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
PyMem_DEL(data);
|
PyMem_Free(data);
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
return PyErr_SetFromWindowsErrWithFunction(rc,
|
return PyErr_SetFromWindowsErrWithFunction(rc,
|
||||||
"RegSetValueEx");
|
"RegSetValueEx");
|
||||||
|
|
|
@ -384,7 +384,7 @@ fstring_compile_expr(Parser *p, const char *expr_start, const char *expr_end,
|
||||||
|
|
||||||
int lines, cols;
|
int lines, cols;
|
||||||
if (!fstring_find_expr_location(t, str, &lines, &cols)) {
|
if (!fstring_find_expr_location(t, str, &lines, &cols)) {
|
||||||
PyMem_FREE(str);
|
PyMem_Free(str);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ static const char* type_comment_prefix = "# type: ";
|
||||||
static struct tok_state *
|
static struct tok_state *
|
||||||
tok_new(void)
|
tok_new(void)
|
||||||
{
|
{
|
||||||
struct tok_state *tok = (struct tok_state *)PyMem_MALLOC(
|
struct tok_state *tok = (struct tok_state *)PyMem_Malloc(
|
||||||
sizeof(struct tok_state));
|
sizeof(struct tok_state));
|
||||||
if (tok == NULL)
|
if (tok == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -93,7 +93,7 @@ tok_new(void)
|
||||||
static char *
|
static char *
|
||||||
new_string(const char *s, Py_ssize_t len, struct tok_state *tok)
|
new_string(const char *s, Py_ssize_t len, struct tok_state *tok)
|
||||||
{
|
{
|
||||||
char* result = (char *)PyMem_MALLOC(len + 1);
|
char* result = (char *)PyMem_Malloc(len + 1);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
tok->done = E_NOMEM;
|
tok->done = E_NOMEM;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -108,7 +108,7 @@ error_ret(struct tok_state *tok) /* XXX */
|
||||||
{
|
{
|
||||||
tok->decoding_erred = 1;
|
tok->decoding_erred = 1;
|
||||||
if (tok->fp != NULL && tok->buf != NULL) /* see PyTokenizer_Free */
|
if (tok->fp != NULL && tok->buf != NULL) /* see PyTokenizer_Free */
|
||||||
PyMem_FREE(tok->buf);
|
PyMem_Free(tok->buf);
|
||||||
tok->buf = tok->cur = tok->inp = NULL;
|
tok->buf = tok->cur = tok->inp = NULL;
|
||||||
tok->start = NULL;
|
tok->start = NULL;
|
||||||
tok->end = NULL;
|
tok->end = NULL;
|
||||||
|
@ -184,7 +184,7 @@ get_coding_spec(const char *s, char **spec, Py_ssize_t size, struct tok_state *t
|
||||||
return 0;
|
return 0;
|
||||||
q = get_normal_name(r);
|
q = get_normal_name(r);
|
||||||
if (r != q) {
|
if (r != q) {
|
||||||
PyMem_FREE(r);
|
PyMem_Free(r);
|
||||||
r = new_string(q, strlen(q), tok);
|
r = new_string(q, strlen(q), tok);
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -244,7 +244,7 @@ check_coding_spec(const char* line, Py_ssize_t size, struct tok_state *tok,
|
||||||
else {
|
else {
|
||||||
PyErr_Format(PyExc_SyntaxError,
|
PyErr_Format(PyExc_SyntaxError,
|
||||||
"encoding problem: %s", cs);
|
"encoding problem: %s", cs);
|
||||||
PyMem_FREE(cs);
|
PyMem_Free(cs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { /* then, compare cs with BOM */
|
} else { /* then, compare cs with BOM */
|
||||||
|
@ -252,7 +252,7 @@ check_coding_spec(const char* line, Py_ssize_t size, struct tok_state *tok,
|
||||||
if (!r)
|
if (!r)
|
||||||
PyErr_Format(PyExc_SyntaxError,
|
PyErr_Format(PyExc_SyntaxError,
|
||||||
"encoding problem: %s with BOM", cs);
|
"encoding problem: %s with BOM", cs);
|
||||||
PyMem_FREE(cs);
|
PyMem_Free(cs);
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -315,7 +315,7 @@ check_bom(int get_char(struct tok_state *),
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (tok->encoding != NULL)
|
if (tok->encoding != NULL)
|
||||||
PyMem_FREE(tok->encoding);
|
PyMem_Free(tok->encoding);
|
||||||
tok->encoding = new_string("utf-8", 5, tok);
|
tok->encoding = new_string("utf-8", 5, tok);
|
||||||
if (!tok->encoding)
|
if (!tok->encoding)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -620,7 +620,7 @@ translate_newlines(const char *s, int exec_input, struct tok_state *tok) {
|
||||||
size_t needed_length = strlen(s) + 2, final_length;
|
size_t needed_length = strlen(s) + 2, final_length;
|
||||||
char *buf, *current;
|
char *buf, *current;
|
||||||
char c = '\0';
|
char c = '\0';
|
||||||
buf = PyMem_MALLOC(needed_length);
|
buf = PyMem_Malloc(needed_length);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
tok->done = E_NOMEM;
|
tok->done = E_NOMEM;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -651,9 +651,9 @@ translate_newlines(const char *s, int exec_input, struct tok_state *tok) {
|
||||||
final_length = current - buf + 1;
|
final_length = current - buf + 1;
|
||||||
if (final_length < needed_length && final_length) {
|
if (final_length < needed_length && final_length) {
|
||||||
/* should never fail */
|
/* should never fail */
|
||||||
char* result = PyMem_REALLOC(buf, final_length);
|
char* result = PyMem_Realloc(buf, final_length);
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
PyMem_FREE(buf);
|
PyMem_Free(buf);
|
||||||
}
|
}
|
||||||
buf = result;
|
buf = result;
|
||||||
}
|
}
|
||||||
|
@ -757,7 +757,7 @@ PyTokenizer_FromUTF8(const char *str, int exec_input)
|
||||||
tok->read_coding_spec = 1;
|
tok->read_coding_spec = 1;
|
||||||
tok->enc = NULL;
|
tok->enc = NULL;
|
||||||
tok->str = translated;
|
tok->str = translated;
|
||||||
tok->encoding = (char *)PyMem_MALLOC(6);
|
tok->encoding = (char *)PyMem_Malloc(6);
|
||||||
if (!tok->encoding) {
|
if (!tok->encoding) {
|
||||||
PyTokenizer_Free(tok);
|
PyTokenizer_Free(tok);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -778,7 +778,7 @@ PyTokenizer_FromFile(FILE *fp, const char* enc,
|
||||||
struct tok_state *tok = tok_new();
|
struct tok_state *tok = tok_new();
|
||||||
if (tok == NULL)
|
if (tok == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
if ((tok->buf = (char *)PyMem_MALLOC(BUFSIZ)) == NULL) {
|
if ((tok->buf = (char *)PyMem_Malloc(BUFSIZ)) == NULL) {
|
||||||
PyTokenizer_Free(tok);
|
PyTokenizer_Free(tok);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -790,7 +790,7 @@ PyTokenizer_FromFile(FILE *fp, const char* enc,
|
||||||
if (enc != NULL) {
|
if (enc != NULL) {
|
||||||
/* Must copy encoding declaration since it
|
/* Must copy encoding declaration since it
|
||||||
gets copied into the parse tree. */
|
gets copied into the parse tree. */
|
||||||
tok->encoding = PyMem_MALLOC(strlen(enc)+1);
|
tok->encoding = PyMem_Malloc(strlen(enc)+1);
|
||||||
if (!tok->encoding) {
|
if (!tok->encoding) {
|
||||||
PyTokenizer_Free(tok);
|
PyTokenizer_Free(tok);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -808,15 +808,15 @@ void
|
||||||
PyTokenizer_Free(struct tok_state *tok)
|
PyTokenizer_Free(struct tok_state *tok)
|
||||||
{
|
{
|
||||||
if (tok->encoding != NULL)
|
if (tok->encoding != NULL)
|
||||||
PyMem_FREE(tok->encoding);
|
PyMem_Free(tok->encoding);
|
||||||
Py_XDECREF(tok->decoding_readline);
|
Py_XDECREF(tok->decoding_readline);
|
||||||
Py_XDECREF(tok->decoding_buffer);
|
Py_XDECREF(tok->decoding_buffer);
|
||||||
Py_XDECREF(tok->filename);
|
Py_XDECREF(tok->filename);
|
||||||
if (tok->fp != NULL && tok->buf != NULL)
|
if (tok->fp != NULL && tok->buf != NULL)
|
||||||
PyMem_FREE(tok->buf);
|
PyMem_Free(tok->buf);
|
||||||
if (tok->input)
|
if (tok->input)
|
||||||
PyMem_FREE(tok->input);
|
PyMem_Free(tok->input);
|
||||||
PyMem_FREE(tok);
|
PyMem_Free(tok);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get next char, updating state; error code goes into tok->done */
|
/* Get next char, updating state; error code goes into tok->done */
|
||||||
|
@ -852,7 +852,7 @@ tok_nextc(struct tok_state *tok)
|
||||||
char *newtok = PyOS_Readline(stdin, stdout, tok->prompt);
|
char *newtok = PyOS_Readline(stdin, stdout, tok->prompt);
|
||||||
if (newtok != NULL) {
|
if (newtok != NULL) {
|
||||||
char *translated = translate_newlines(newtok, 0, tok);
|
char *translated = translate_newlines(newtok, 0, tok);
|
||||||
PyMem_FREE(newtok);
|
PyMem_Free(newtok);
|
||||||
if (translated == NULL)
|
if (translated == NULL)
|
||||||
return EOF;
|
return EOF;
|
||||||
newtok = translated;
|
newtok = translated;
|
||||||
|
@ -862,14 +862,14 @@ tok_nextc(struct tok_state *tok)
|
||||||
Py_ssize_t buflen;
|
Py_ssize_t buflen;
|
||||||
const char* buf;
|
const char* buf;
|
||||||
PyObject *u = translate_into_utf8(newtok, tok->encoding);
|
PyObject *u = translate_into_utf8(newtok, tok->encoding);
|
||||||
PyMem_FREE(newtok);
|
PyMem_Free(newtok);
|
||||||
if (!u) {
|
if (!u) {
|
||||||
tok->done = E_DECODE;
|
tok->done = E_DECODE;
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
buflen = PyBytes_GET_SIZE(u);
|
buflen = PyBytes_GET_SIZE(u);
|
||||||
buf = PyBytes_AS_STRING(u);
|
buf = PyBytes_AS_STRING(u);
|
||||||
newtok = PyMem_MALLOC(buflen+1);
|
newtok = PyMem_Malloc(buflen+1);
|
||||||
if (newtok == NULL) {
|
if (newtok == NULL) {
|
||||||
Py_DECREF(u);
|
Py_DECREF(u);
|
||||||
tok->done = E_NOMEM;
|
tok->done = E_NOMEM;
|
||||||
|
@ -883,7 +883,7 @@ tok_nextc(struct tok_state *tok)
|
||||||
if (newtok == NULL)
|
if (newtok == NULL)
|
||||||
tok->done = E_INTR;
|
tok->done = E_INTR;
|
||||||
else if (*newtok == '\0') {
|
else if (*newtok == '\0') {
|
||||||
PyMem_FREE(newtok);
|
PyMem_Free(newtok);
|
||||||
tok->done = E_EOF;
|
tok->done = E_EOF;
|
||||||
}
|
}
|
||||||
else if (tok->start != NULL) {
|
else if (tok->start != NULL) {
|
||||||
|
@ -892,12 +892,12 @@ tok_nextc(struct tok_state *tok)
|
||||||
size_t newlen = oldlen + strlen(newtok);
|
size_t newlen = oldlen + strlen(newtok);
|
||||||
Py_ssize_t cur_multi_line_start = tok->multi_line_start - tok->buf;
|
Py_ssize_t cur_multi_line_start = tok->multi_line_start - tok->buf;
|
||||||
char *buf = tok->buf;
|
char *buf = tok->buf;
|
||||||
buf = (char *)PyMem_REALLOC(buf, newlen+1);
|
buf = (char *)PyMem_Realloc(buf, newlen+1);
|
||||||
tok->lineno++;
|
tok->lineno++;
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
PyMem_FREE(tok->buf);
|
PyMem_Free(tok->buf);
|
||||||
tok->buf = NULL;
|
tok->buf = NULL;
|
||||||
PyMem_FREE(newtok);
|
PyMem_Free(newtok);
|
||||||
tok->done = E_NOMEM;
|
tok->done = E_NOMEM;
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
|
@ -906,7 +906,7 @@ tok_nextc(struct tok_state *tok)
|
||||||
tok->multi_line_start = tok->buf + cur_multi_line_start;
|
tok->multi_line_start = tok->buf + cur_multi_line_start;
|
||||||
tok->line_start = tok->cur;
|
tok->line_start = tok->cur;
|
||||||
strcpy(tok->buf + oldlen, newtok);
|
strcpy(tok->buf + oldlen, newtok);
|
||||||
PyMem_FREE(newtok);
|
PyMem_Free(newtok);
|
||||||
tok->inp = tok->buf + newlen;
|
tok->inp = tok->buf + newlen;
|
||||||
tok->end = tok->inp + 1;
|
tok->end = tok->inp + 1;
|
||||||
tok->start = tok->buf + start;
|
tok->start = tok->buf + start;
|
||||||
|
@ -914,7 +914,7 @@ tok_nextc(struct tok_state *tok)
|
||||||
else {
|
else {
|
||||||
tok->lineno++;
|
tok->lineno++;
|
||||||
if (tok->buf != NULL)
|
if (tok->buf != NULL)
|
||||||
PyMem_FREE(tok->buf);
|
PyMem_Free(tok->buf);
|
||||||
tok->buf = newtok;
|
tok->buf = newtok;
|
||||||
tok->cur = tok->buf;
|
tok->cur = tok->buf;
|
||||||
tok->line_start = tok->buf;
|
tok->line_start = tok->buf;
|
||||||
|
@ -929,7 +929,7 @@ tok_nextc(struct tok_state *tok)
|
||||||
if (tok->start == NULL) {
|
if (tok->start == NULL) {
|
||||||
if (tok->buf == NULL) {
|
if (tok->buf == NULL) {
|
||||||
tok->buf = (char *)
|
tok->buf = (char *)
|
||||||
PyMem_MALLOC(BUFSIZ);
|
PyMem_Malloc(BUFSIZ);
|
||||||
if (tok->buf == NULL) {
|
if (tok->buf == NULL) {
|
||||||
tok->done = E_NOMEM;
|
tok->done = E_NOMEM;
|
||||||
return EOF;
|
return EOF;
|
||||||
|
@ -966,7 +966,7 @@ tok_nextc(struct tok_state *tok)
|
||||||
Py_ssize_t curvalid = tok->inp - tok->buf;
|
Py_ssize_t curvalid = tok->inp - tok->buf;
|
||||||
Py_ssize_t newsize = curvalid + BUFSIZ;
|
Py_ssize_t newsize = curvalid + BUFSIZ;
|
||||||
char *newbuf = tok->buf;
|
char *newbuf = tok->buf;
|
||||||
newbuf = (char *)PyMem_REALLOC(newbuf,
|
newbuf = (char *)PyMem_Realloc(newbuf,
|
||||||
newsize);
|
newsize);
|
||||||
if (newbuf == NULL) {
|
if (newbuf == NULL) {
|
||||||
tok->done = E_NOMEM;
|
tok->done = E_NOMEM;
|
||||||
|
@ -1851,7 +1851,7 @@ PyTokenizer_Get(struct tok_state *tok, const char **p_start, const char **p_end)
|
||||||
encoding in the first or second line of the file (in which case the encoding
|
encoding in the first or second line of the file (in which case the encoding
|
||||||
should be assumed to be UTF-8).
|
should be assumed to be UTF-8).
|
||||||
|
|
||||||
The char* returned is malloc'ed via PyMem_MALLOC() and thus must be freed
|
The char* returned is malloc'ed via PyMem_Malloc() and thus must be freed
|
||||||
by the caller. */
|
by the caller. */
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
@ -1894,7 +1894,7 @@ PyTokenizer_FindEncodingFilename(int fd, PyObject *filename)
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
if (tok->encoding) {
|
if (tok->encoding) {
|
||||||
encoding = (char *)PyMem_MALLOC(strlen(tok->encoding) + 1);
|
encoding = (char *)PyMem_Malloc(strlen(tok->encoding) + 1);
|
||||||
if (encoding)
|
if (encoding)
|
||||||
strcpy(encoding, tok->encoding);
|
strcpy(encoding, tok->encoding);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2089,7 +2089,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
|
||||||
Py_DECREF(stdin_encoding);
|
Py_DECREF(stdin_encoding);
|
||||||
Py_DECREF(stdin_errors);
|
Py_DECREF(stdin_errors);
|
||||||
Py_XDECREF(po);
|
Py_XDECREF(po);
|
||||||
PyMem_FREE(s);
|
PyMem_Free(s);
|
||||||
|
|
||||||
if (result != NULL) {
|
if (result != NULL) {
|
||||||
if (PySys_Audit("builtins.input/result", "O", result) < 0) {
|
if (PySys_Audit("builtins.input/result", "O", result) < 0) {
|
||||||
|
|
|
@ -202,7 +202,7 @@ static int
|
||||||
cleanup_ptr(PyObject *self, void *ptr)
|
cleanup_ptr(PyObject *self, void *ptr)
|
||||||
{
|
{
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
PyMem_FREE(ptr);
|
PyMem_Free(ptr);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ cleanreturn(int retval, freelist_t *freelist)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (freelist->entries_malloced)
|
if (freelist->entries_malloced)
|
||||||
PyMem_FREE(freelist->entries);
|
PyMem_Free(freelist->entries);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -638,7 +638,7 @@ r_string(Py_ssize_t n, RFILE *p)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
if (p->buf == NULL) {
|
if (p->buf == NULL) {
|
||||||
p->buf = PyMem_MALLOC(n);
|
p->buf = PyMem_Malloc(n);
|
||||||
if (p->buf == NULL) {
|
if (p->buf == NULL) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -646,7 +646,7 @@ r_string(Py_ssize_t n, RFILE *p)
|
||||||
p->buf_size = n;
|
p->buf_size = n;
|
||||||
}
|
}
|
||||||
else if (p->buf_size < n) {
|
else if (p->buf_size < n) {
|
||||||
char *tmp = PyMem_REALLOC(p->buf, n);
|
char *tmp = PyMem_Realloc(p->buf, n);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1453,7 +1453,7 @@ PyMarshal_ReadShortFromFile(FILE *fp)
|
||||||
rf.buf = NULL;
|
rf.buf = NULL;
|
||||||
res = r_short(&rf);
|
res = r_short(&rf);
|
||||||
if (rf.buf != NULL)
|
if (rf.buf != NULL)
|
||||||
PyMem_FREE(rf.buf);
|
PyMem_Free(rf.buf);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1468,7 +1468,7 @@ PyMarshal_ReadLongFromFile(FILE *fp)
|
||||||
rf.buf = NULL;
|
rf.buf = NULL;
|
||||||
res = r_long(&rf);
|
res = r_long(&rf);
|
||||||
if (rf.buf != NULL)
|
if (rf.buf != NULL)
|
||||||
PyMem_FREE(rf.buf);
|
PyMem_Free(rf.buf);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1501,11 +1501,11 @@ PyMarshal_ReadLastObjectFromFile(FILE *fp)
|
||||||
off_t filesize;
|
off_t filesize;
|
||||||
filesize = getfilesize(fp);
|
filesize = getfilesize(fp);
|
||||||
if (filesize > 0 && filesize <= REASONABLE_FILE_LIMIT) {
|
if (filesize > 0 && filesize <= REASONABLE_FILE_LIMIT) {
|
||||||
char* pBuf = (char *)PyMem_MALLOC(filesize);
|
char* pBuf = (char *)PyMem_Malloc(filesize);
|
||||||
if (pBuf != NULL) {
|
if (pBuf != NULL) {
|
||||||
size_t n = fread(pBuf, 1, (size_t)filesize, fp);
|
size_t n = fread(pBuf, 1, (size_t)filesize, fp);
|
||||||
PyObject* v = PyMarshal_ReadObjectFromString(pBuf, n);
|
PyObject* v = PyMarshal_ReadObjectFromString(pBuf, n);
|
||||||
PyMem_FREE(pBuf);
|
PyMem_Free(pBuf);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1534,7 +1534,7 @@ PyMarshal_ReadObjectFromFile(FILE *fp)
|
||||||
result = r_object(&rf);
|
result = r_object(&rf);
|
||||||
Py_DECREF(rf.refs);
|
Py_DECREF(rf.refs);
|
||||||
if (rf.buf != NULL)
|
if (rf.buf != NULL)
|
||||||
PyMem_FREE(rf.buf);
|
PyMem_Free(rf.buf);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1555,7 +1555,7 @@ PyMarshal_ReadObjectFromString(const char *str, Py_ssize_t len)
|
||||||
result = r_object(&rf);
|
result = r_object(&rf);
|
||||||
Py_DECREF(rf.refs);
|
Py_DECREF(rf.refs);
|
||||||
if (rf.buf != NULL)
|
if (rf.buf != NULL)
|
||||||
PyMem_FREE(rf.buf);
|
PyMem_Free(rf.buf);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1684,7 +1684,7 @@ marshal_load(PyObject *module, PyObject *file)
|
||||||
result = read_object(&rf);
|
result = read_object(&rf);
|
||||||
Py_DECREF(rf.refs);
|
Py_DECREF(rf.refs);
|
||||||
if (rf.buf != NULL)
|
if (rf.buf != NULL)
|
||||||
PyMem_FREE(rf.buf);
|
PyMem_Free(rf.buf);
|
||||||
} else
|
} else
|
||||||
result = NULL;
|
result = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,7 +255,7 @@ _PyOS_ascii_strtod(const char *nptr, char **endptr)
|
||||||
char *copy, *c;
|
char *copy, *c;
|
||||||
/* Create a copy of the input, with the '.' converted to the
|
/* Create a copy of the input, with the '.' converted to the
|
||||||
locale-specific decimal point */
|
locale-specific decimal point */
|
||||||
copy = (char *)PyMem_MALLOC(end - digits_pos +
|
copy = (char *)PyMem_Malloc(end - digits_pos +
|
||||||
1 + decimal_point_len);
|
1 + decimal_point_len);
|
||||||
if (copy == NULL) {
|
if (copy == NULL) {
|
||||||
*endptr = (char *)nptr;
|
*endptr = (char *)nptr;
|
||||||
|
@ -286,7 +286,7 @@ _PyOS_ascii_strtod(const char *nptr, char **endptr)
|
||||||
(fail_pos - copy);
|
(fail_pos - copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyMem_FREE(copy);
|
PyMem_Free(copy);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -419,12 +419,12 @@ _Py_DisplaySourceLine(PyObject *f, PyObject *filename, int lineno, int indent)
|
||||||
if (lseek(fd, 0, SEEK_SET) == (off_t)-1) {
|
if (lseek(fd, 0, SEEK_SET) == (off_t)-1) {
|
||||||
Py_DECREF(io);
|
Py_DECREF(io);
|
||||||
Py_DECREF(binary);
|
Py_DECREF(binary);
|
||||||
PyMem_FREE(found_encoding);
|
PyMem_Free(found_encoding);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
fob = _PyObject_CallMethodId(io, &PyId_TextIOWrapper, "Os", binary, encoding);
|
fob = _PyObject_CallMethodId(io, &PyId_TextIOWrapper, "Os", binary, encoding);
|
||||||
Py_DECREF(io);
|
Py_DECREF(io);
|
||||||
PyMem_FREE(found_encoding);
|
PyMem_Free(found_encoding);
|
||||||
|
|
||||||
if (fob == NULL) {
|
if (fob == NULL) {
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
|
|
Loading…
Reference in New Issue