summaryrefslogtreecommitdiff
path: root/Modules/audioop.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-07-07 16:21:41 +0200
committerVictor Stinner <victor.stinner@gmail.com>2013-07-07 16:21:41 +0200
commitb64049183cee61edc112eefa3ca76916d03e9f02 (patch)
treefd0be14ac288739314a5108c6e21879f641b0b40 /Modules/audioop.c
parent1a7425f67a0d141483d89ca80ca01e3cb7f6be92 (diff)
downloadcpython-git-b64049183cee61edc112eefa3ca76916d03e9f02.tar.gz
Issue #18203: Replace malloc() with PyMem_Malloc() in Python modules
Replace malloc() with PyMem_Malloc() when the GIL is held, or with PyMem_RawMalloc() otherwise.
Diffstat (limited to 'Modules/audioop.c')
-rw-r--r--Modules/audioop.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/Modules/audioop.c b/Modules/audioop.c
index 4f2b25f33a..7175cec7c7 100644
--- a/Modules/audioop.c
+++ b/Modules/audioop.c
@@ -1137,8 +1137,8 @@ audioop_ratecv(PyObject *self, PyObject *args)
"not enough memory for output buffer");
return 0;
}
- prev_i = (int *) malloc(nchannels * sizeof(int));
- cur_i = (int *) malloc(nchannels * sizeof(int));
+ prev_i = (int *) PyMem_Malloc(nchannels * sizeof(int));
+ cur_i = (int *) PyMem_Malloc(nchannels * sizeof(int));
if (prev_i == NULL || cur_i == NULL) {
(void) PyErr_NoMemory();
goto exit;
@@ -1257,10 +1257,8 @@ audioop_ratecv(PyObject *self, PyObject *args)
}
}
exit:
- if (prev_i != NULL)
- free(prev_i);
- if (cur_i != NULL)
- free(cur_i);
+ PyMem_Free(prev_i);
+ PyMem_Free(cur_i);
return rv;
}