annotate Python/asdl.c @ 46567:ffeecbebf3ca

Block 2.6-only doc change.
author Georg Brandl <georg@python.org>
date Sat, 26 Apr 2008 18:28:08 +0000
parents f731859e9b3b
children ac854cde3135
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1 #include "Python.h"
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2 #include "asdl.h"
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
3
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
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
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
6 {
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
7 asdl_seq *seq = NULL;
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
8 size_t n = sizeof(asdl_seq) +
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
9 (size ? (sizeof(void *) * (size - 1)) : 0);
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
10
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36718
diff changeset
11 seq = (asdl_seq *)PyArena_Malloc(arena, n);
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
12 if (!seq) {
35869
9003836a036f Use convenience function
Neal Norwitz <nnorwitz@gmail.com>
parents: 35866
diff changeset
13 PyErr_NoMemory();
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
14 return NULL;
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
15 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
16 memset(seq, 0, n);
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
17 seq->size = size;
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
18 return seq;
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
19 }
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36718
diff changeset
20
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36718
diff changeset
21 asdl_int_seq *
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36718
diff changeset
22 asdl_int_seq_new(int size, PyArena *arena)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36718
diff changeset
23 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36718
diff changeset
24 asdl_int_seq *seq = NULL;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36718
diff changeset
25 size_t n = sizeof(asdl_seq) +
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36718
diff changeset
26 (size ? (sizeof(int) * (size - 1)) : 0);
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36718
diff changeset
27
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36718
diff changeset
28 seq = (asdl_int_seq *)PyArena_Malloc(arena, n);
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36718
diff changeset
29 if (!seq) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36718
diff changeset
30 PyErr_NoMemory();
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36718
diff changeset
31 return NULL;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36718
diff changeset
32 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36718
diff changeset
33 memset(seq, 0, n);
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36718
diff changeset
34 seq->size = size;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36718
diff changeset
35 return seq;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36718
diff changeset
36 }