Exemplo n.º 1
0
Arquivo: gc_mns.c Projeto: hanjoes/gc
static void *gc_alloc(int size) {
    void *o = gc_alloc_space(size);
    if(NULL == o) {
        gc_clear_mark();
        gc_mark();
        o = gc_alloc_space(size);
        if (o == NULL) {
            if (DEBUG) printf("memory is full");
            return NULL;
        }
    }
    return o;
}
Exemplo n.º 2
0
Vector *gc_alloc_vector(int size) {
	Vector *v = gc_alloc_space(sizeof(Vector) + size * sizeof(double)+1);
	v->header.marked = 0;
	v->length = size;
	v->name = "Vector";
	memset(v->data, 0, size*sizeof(double));
	gc_add_objects(v);
	return v;
}
Exemplo n.º 3
0
String *gc_alloc_string(int size) {
	String *s;
	s = (String *) gc_alloc_space(sizeof (String) + size + 1);
	s->header.marked = 0;
	memset(s->str, 0, size);
	s->length = size;
	s->name = "String";
	gc_add_objects(s);
	return s;
}