source: vendor/python/2.5/Python/pyarena.c@ 3225

Last change on this file since 3225 was 3225, checked in by bird, 19 years ago

Python 2.5

File size: 5.8 KB
Line 
1#include "Python.h"
2#include "pyarena.h"
3
4/* A simple arena block structure.
5
6 Measurements with standard library modules suggest the average
7 allocation is about 20 bytes and that most compiles use a single
8 block.
9
10 TODO(jhylton): Think about a realloc API, maybe just for the last
11 allocation?
12*/
13
14#define DEFAULT_BLOCK_SIZE 8192
15#define ALIGNMENT 8
16#define ALIGNMENT_MASK (ALIGNMENT - 1)
17#define ROUNDUP(x) (((x) + ALIGNMENT_MASK) & ~ALIGNMENT_MASK)
18
19typedef struct _block {
20 /* Total number of bytes owned by this block available to pass out.
21 * Read-only after initialization. The first such byte starts at
22 * ab_mem.
23 */
24 size_t ab_size;
25
26 /* Total number of bytes already passed out. The next byte available
27 * to pass out starts at ab_mem + ab_offset.
28 */
29 size_t ab_offset;
30
31 /* An arena maintains a singly-linked, NULL-terminated list of
32 * all blocks owned by the arena. These are linked via the
33 * ab_next member.
34 */
35 struct _block *ab_next;