Mercurial > cpython-lru_cache-weakref
annotate Python/asdl.c @ 36065:ea083efdc96c legacy-trunk
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.
| author | Neal Norwitz <nnorwitz@gmail.com> |
|---|---|
| date | Sat, 17 Dec 2005 20:54:49 +0000 |
| parents | 9003836a036f |
| children | 45e6f901902c |
| 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 | |
|
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
|
11 seq = (asdl_seq *)malloc(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 } | |
|
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
|
16 PyArena_AddMallocPointer(arena, (void *)seq); |
| 35742 | 17 memset(seq, 0, n); |
| 18 seq->size = size; | |
| 19 return seq; | |
| 20 } | |
| 21 | |
| 22 void | |
| 23 asdl_seq_free(asdl_seq *seq) | |
| 24 { | |
| 25 } |
