Staging
v0.8.1
https://github.com/python/cpython
Revision a93ee47422ba80ffc75465255df278e174ee803d authored by Phillip J. Eby on 21 April 2006, 21:53:37 UTC, committed by Phillip J. Eby on 21 April 2006, 21:53:37 UTC
1 parent 21fbd57
Raw File
Tip revision: a93ee47422ba80ffc75465255df278e174ee803d authored by Phillip J. Eby on 21 April 2006, 21:53:37 UTC
Guido wrote contextlib, not me, but thanks anyway. ;)
Tip revision: a93ee47
asdl.c
#include "Python.h"
#include "asdl.h"

asdl_seq *
asdl_seq_new(int size, PyArena *arena)
{
	asdl_seq *seq = NULL;
	size_t n = sizeof(asdl_seq) +
			(size ? (sizeof(void *) * (size - 1)) : 0);

	seq = (asdl_seq *)PyArena_Malloc(arena, n);
	if (!seq) {
		PyErr_NoMemory();
		return NULL;
	}
	memset(seq, 0, n);
	seq->size = size;
	return seq;
}

asdl_int_seq *
asdl_int_seq_new(int size, PyArena *arena)
{
	asdl_int_seq *seq = NULL;
	size_t n = sizeof(asdl_seq) +
			(size ? (sizeof(int) * (size - 1)) : 0);

	seq = (asdl_int_seq *)PyArena_Malloc(arena, n);
	if (!seq) {
		PyErr_NoMemory();
		return NULL;
	}
	memset(seq, 0, n);
	seq->size = size;
	return seq;
}
back to top