void Init_PreGC(void) { auto_collection_control_t *control; #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 __auto_zone = objc_collectableZone(); #else __auto_zone = auto_zone(); #endif if (__auto_zone == NULL) { rb_objc_no_gc_error(); } __nsobject = (void *)objc_getClass("NSObject"); control = auto_collection_parameters(__auto_zone); if (getenv("GC_DEBUG")) { control->log = AUTO_LOG_COLLECTIONS | AUTO_LOG_REGIONS | AUTO_LOG_UNUSUAL; } if (getenv("GC_DISABLE")) { gc_disabled = true; auto_collector_disable(__auto_zone); } }
void Init_PreGC(void) { auto_collection_control_t *control; __auto_zone = auto_zone(); if (__auto_zone == NULL) { rb_objc_no_gc_error(); } __nsobject = (void *)objc_getClass("NSObject"); control = auto_collection_parameters(__auto_zone); if (getenv("GC_DEBUG")) { control->log = AUTO_LOG_COLLECTIONS | AUTO_LOG_REGIONS | AUTO_LOG_UNUSUAL; } if (getenv("GC_DISABLE")) { gc_disabled = true; } Method m = class_getInstanceMethod((Class)objc_getClass("NSObject"), sel_registerName("finalize")); assert(m != NULL); method_setImplementation(m, (IMP)rb_obj_imp_finalize); auto_collector_disable(__auto_zone); }
static inline void * ruby_xmalloc_memory(size_t size, int type) { assert(size > 0); if (__auto_zone == NULL) { rb_objc_no_gc_error(); } void *mem = auto_zone_allocate_object(__auto_zone, size, type, 0, 0); if (mem == NULL) { rb_memerror(); } return mem; }
void * ruby_xmalloc(size_t size) { void *mem; if (size < 0) { rb_raise(rb_eNoMemError, "negative allocation size (or too big)"); } if (size == 0) { size = 1; } if (__auto_zone == NULL) { rb_objc_no_gc_error(); } mem = auto_zone_allocate_object(__auto_zone, size, AUTO_MEMORY_SCANNED, 0, 0); if (mem == NULL) { rb_memerror(); } return mem; }
static inline void * ruby_xmalloc_memory(size_t size, int type) { if ((ssize_t)size < 0) { negative_size_allocation_error("negative allocation size (or too big)"); } if (size == 0) { size = 1; } if (__auto_zone == NULL) { rb_objc_no_gc_error(); } if (stress_gc && !dont_gc) { garbage_collect(); } void *mem = auto_zone_allocate_object(__auto_zone, size, type, 0, 0); if (mem == NULL) { rb_memerror(); } return mem; }