summaryrefslogtreecommitdiffstats
path: root/Python/asdl.c
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2005-12-17 20:54:49 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2005-12-17 20:54:49 (GMT)
commitadb69fcdffdc50ee3e1d33b00cd874020197b445 (patch)
tree9ea2ddcf5d0625a43739da1d5db7915ef597c8b1 /Python/asdl.c
parent23a695891069f619b5b992d877820558bb8dc70f (diff)
downloadcpython-adb69fcdffdc50ee3e1d33b00cd874020197b445.zip
cpython-adb69fcdffdc50ee3e1d33b00cd874020197b445.tar.gz
cpython-adb69fcdffdc50ee3e1d33b00cd874020197b445.tar.bz2
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
simplifies a lot of error handling code, and fixes many memory leaks.
Diffstat (limited to 'Python/asdl.c')
-rw-r--r--Python/asdl.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/Python/asdl.c b/Python/asdl.c
index 07ad4b3..ccd8714 100644
--- a/Python/asdl.c
+++ b/Python/asdl.c
@@ -2,17 +2,18 @@
#include "asdl.h"
asdl_seq *
-asdl_seq_new(int size)
+asdl_seq_new(int size, PyArena *arena)
{
asdl_seq *seq = NULL;
size_t n = sizeof(asdl_seq) +
(size ? (sizeof(void *) * (size - 1)) : 0);
- seq = (asdl_seq *)PyObject_Malloc(n);
+ seq = (asdl_seq *)malloc(n);
if (!seq) {
PyErr_NoMemory();
return NULL;
}
+ PyArena_AddMallocPointer(arena, (void *)seq);
memset(seq, 0, n);
seq->size = size;
return seq;
@@ -21,6 +22,4 @@ asdl_seq_new(int size)
void
asdl_seq_free(asdl_seq *seq)
{
- PyObject_Free(seq);
}
-