示例#1
0
文件: gc.c 项目: prototype/MacRuby
void *
ruby_xrealloc(void *ptr, size_t size)
{
    void *mem;

    if (size < 0) {
	rb_raise(rb_eArgError, "negative re-allocation size");
    }
    if (ptr == NULL) {
	return ruby_xmalloc(size);
    }
    if (size == 0) {
	size = 1;
    }
    
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
    {
	size_t old_size = malloc_size(ptr);
	if (old_size >= size) {
	    return ptr;
	}
	mem = ruby_xmalloc(size);
	if (mem == NULL) {
	    rb_memerror();
	}
	auto_zone_write_barrier_memmove(__auto_zone, mem, ptr, old_size);
	xfree(ptr);
    }
#else
    mem = malloc_zone_realloc(__auto_zone, ptr, size);

    if (mem == NULL) {
	rb_memerror();
    }
#endif

    return mem;
}
示例#2
0
文件: gc.c 项目: 1nueve/MacRuby
void *
rb_gc_memmove(void *dst, const void *src, size_t len)
{
    return auto_zone_write_barrier_memmove(__auto_zone, dst, src, len);
}