void * mono_gc_alloc_obj (MonoVTable *vtable, size_t size) { MonoObject *obj; if (!vtable->klass->has_references) { obj = GC_MALLOC_ATOMIC (size); obj->vtable = vtable; obj->synchronisation = NULL; memset ((char *) obj + sizeof (MonoObject), 0, size - sizeof (MonoObject)); } else if (vtable->gc_descr != GC_NO_DESCRIPTOR) { obj = GC_GCJ_MALLOC (size, vtable); } else { obj = GC_MALLOC (size); obj->vtable = vtable; } if (G_UNLIKELY (alloc_events)) mono_profiler_allocation (obj); return obj; }
void * mono_gc_alloc_array (MonoVTable *vtable, size_t size, uintptr_t max_length, uintptr_t bounds_size) { MonoArray *obj; if (!vtable->klass->has_references) { obj = GC_MALLOC_ATOMIC (size); obj->obj.vtable = vtable; obj->obj.synchronisation = NULL; memset ((char *) obj + sizeof (MonoObject), 0, size - sizeof (MonoObject)); } else if (vtable->gc_descr != GC_NO_DESCRIPTOR) { obj = GC_GCJ_MALLOC (size, vtable); } else { obj = GC_MALLOC (size); obj->obj.vtable = vtable; } obj->max_length = max_length; if (bounds_size) obj->bounds = (MonoArrayBounds *) ((char *) obj + size - bounds_size); if (G_UNLIKELY (alloc_events)) mono_profiler_allocation (&obj->obj); return obj; }
sexpr gcj_cons(sexpr x, sexpr y) { GC_word * r; sexpr result; r = (GC_word *) GC_GCJ_MALLOC(sizeof(struct SEXPR) + sizeof(struct fake_vtable*), &gcj_class_struct2); if (r == 0) { GC_printf("Out of memory\n"); exit(1); } result = (sexpr)(r + 1); result -> sexpr_car = x; result -> sexpr_cdr = y; return(result); }