Mercurial > cpython-lru_cache-weakref
annotate Python/asdl.c @ 37034:fff4eecdef45 legacy-trunk
Fix a leak that would happen under error conditions (found by Coverty).
| author | Thomas Heller <theller@ctypes.org> |
|---|---|
| date | Thu, 16 Mar 2006 20:02:36 +0000 |
| parents | 45e6f901902c |
| children | 5e72b0c74100 f731859e9b3b |
| rev | line source |
|---|---|
| 35742 | 1 #include "Python.h" |
| 2 #include "asdl.h" | |
| 3 | |
| 4 asdl_seq * | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
35869
diff
changeset
|
5 asdl_seq_new(int size, PyArena *arena) |
| 35742 | 6 { |
| 7 asdl_seq *seq = NULL; | |
| 8 size_t n = sizeof(asdl_seq) + | |
| 9 (size ? (sizeof(void *) * (size - 1)) : 0); | |
| 10 | |
|
36718
45e6f901902c
Remove asdl_seq_APPEND() and simplify asdl seq implementation.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
36065
diff
changeset
|
11 seq = (asdl_seq *)PyArena_Malloc(arena, n); |
| 35742 | 12 if (!seq) { |
|
35869
9003836a036f
Use convenience function
Neal Norwitz <nnorwitz@gmail.com>
parents:
35866
diff
changeset
|
13 PyErr_NoMemory(); |
| 35742 | 14 return NULL; |
| 15 } | |
| 16 memset(seq, 0, n); | |
| 17 seq->size = size; | |
| 18 return seq; | |
| 19 } |
