Mercurial > cpython-lru_cache-weakref
annotate Python/asdl.c @ 44825:ef859cd754a7 legacy-trunk
Fixed a wrong assumption in configure.in and Include/pyport.h. The is finite function is not called isfinite() but finite(). Sorry, my fault. :)
| author | Christian Heimes <christian@cheimes.de> |
|---|---|
| date | Sun, 20 Jan 2008 14:28:28 +0000 |
| parents | 1b5b16cdbe0e |
| children | 8cbe0bd93c28 |
| 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 | |
|
37685
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
36718
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 } | |
|
37685
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
36718
diff
changeset
|
20 |
|
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
36718
diff
changeset
|
21 asdl_int_seq * |
|
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
36718
diff
changeset
|
22 asdl_int_seq_new(int size, PyArena *arena) |
|
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
36718
diff
changeset
|
23 { |
| 37689 | 24 asdl_int_seq *seq = NULL; |
|
37685
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
36718
diff
changeset
|
25 size_t n = sizeof(asdl_seq) + |
|
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
36718
diff
changeset
|
26 (size ? (sizeof(int) * (size - 1)) : 0); |
|
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
36718
diff
changeset
|
27 |
| 37689 | 28 seq = (asdl_int_seq *)PyArena_Malloc(arena, n); |
|
37685
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
36718
diff
changeset
|
29 if (!seq) { |
|
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
36718
diff
changeset
|
30 PyErr_NoMemory(); |
|
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
36718
diff
changeset
|
31 return NULL; |
|
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
36718
diff
changeset
|
32 } |
|
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
36718
diff
changeset
|
33 memset(seq, 0, n); |
|
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
36718
diff
changeset
|
34 seq->size = size; |
|
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
36718
diff
changeset
|
35 return seq; |
|
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
36718
diff
changeset
|
36 } |
