Trimmed trailing whitespace.
This commit is contained in:
parent
2e63b73a2c
commit
8cfaa0e729
|
@ -26,7 +26,7 @@ extern "C" {
|
||||||
/* This routines isn't a proper arena allocation routine. It takes
|
/* This routines isn't a proper arena allocation routine. It takes
|
||||||
a PyObject* and records it so that it can be DECREFed when the
|
a PyObject* and records it so that it can be DECREFed when the
|
||||||
arena is freed.
|
arena is freed.
|
||||||
*/
|
*/
|
||||||
PyAPI_FUNC(int) PyArena_AddPyObject(PyArena *, PyObject *);
|
PyAPI_FUNC(int) PyArena_AddPyObject(PyArena *, PyObject *);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include "pyarena.h"
|
#include "pyarena.h"
|
||||||
|
|
||||||
/* A simple arena block structure
|
/* A simple arena block structure
|
||||||
|
|
||||||
Measurements with standard library modules suggest the average
|
Measurements with standard library modules suggest the average
|
||||||
allocation is about 20 bytes and that most compiles use a single
|
allocation is about 20 bytes and that most compiles use a single
|
||||||
|
@ -20,7 +20,7 @@ typedef struct _block {
|
||||||
and a list of PyObject* pointers. PyObjects are decrefed
|
and a list of PyObject* pointers. PyObjects are decrefed
|
||||||
when the arena is freed.
|
when the arena is freed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct _arena {
|
struct _arena {
|
||||||
block *a_head;
|
block *a_head;
|
||||||
block *a_cur;
|
block *a_cur;
|
||||||
|
@ -38,7 +38,7 @@ struct _arena {
|
||||||
static block *
|
static block *
|
||||||
block_new(size_t size)
|
block_new(size_t size)
|
||||||
{
|
{
|
||||||
/* Allocate header and block as one unit.
|
/* Allocate header and block as one unit.
|
||||||
ab_mem points just past header. */
|
ab_mem points just past header. */
|
||||||
block *b = (block *)malloc(sizeof(block) + size);
|
block *b = (block *)malloc(sizeof(block) + size);
|
||||||
if (!b)
|
if (!b)
|
||||||
|
@ -120,7 +120,7 @@ PyArena_Free(PyArena *arena)
|
||||||
assert(arena);
|
assert(arena);
|
||||||
#if defined(Py_DEBUG)
|
#if defined(Py_DEBUG)
|
||||||
/*
|
/*
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"alloc=%d size=%d blocks=%d block_size=%d big=%d objects=%d\n",
|
"alloc=%d size=%d blocks=%d block_size=%d big=%d objects=%d\n",
|
||||||
arena->total_allocs, arena->total_size, arena->total_blocks,
|
arena->total_allocs, arena->total_size, arena->total_blocks,
|
||||||
arena->total_block_size, arena->total_big_blocks,
|
arena->total_block_size, arena->total_big_blocks,
|
||||||
|
@ -134,7 +134,7 @@ PyArena_Free(PyArena *arena)
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
PyArena_Malloc(PyArena *arena, size_t size)
|
PyArena_Malloc(PyArena *arena, size_t size)
|
||||||
{
|
{
|
||||||
void *p = block_alloc(arena->a_cur, size);
|
void *p = block_alloc(arena->a_cur, size);
|
||||||
if (!p)
|
if (!p)
|
||||||
|
@ -157,7 +157,7 @@ PyArena_Malloc(PyArena *arena, size_t size)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PyArena_AddPyObject(PyArena *arena, PyObject *obj)
|
PyArena_AddPyObject(PyArena *arena, PyObject *obj)
|
||||||
{
|
{
|
||||||
int r = PyList_Append(arena->a_objects, obj);
|
int r = PyList_Append(arena->a_objects, obj);
|
||||||
if (r >= 0) {
|
if (r >= 0) {
|
||||||
|
|
Loading…
Reference in New Issue