--- parser3/src/main/pa_memory.C 2003/04/01 15:42:26 1.1.2.5.2.10 +++ parser3/src/main/pa_memory.C 2005/08/05 13:03:02 1.5.14.1 @@ -1,21 +1,21 @@ /** @file Parser: memory reference counting classes. - Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_MEMORY_C="$Date: 2003/04/01 15:42:26 $"; +static const char * const IDENT_MEMORY_C="$Date: 2005/08/05 13:03:02 $"; #include "pa_sapi.h" #include "pa_common.h" void *pa_fail_alloc(const char* what, size_t size) { #ifdef PA_DEBUG_DISABLE_GC - SAPI::abort("xx"); + SAPI::die("out of memory (in pa_fail_alloc)"); #else - SAPI::abort("out of memory: failed to %s %u bytes. " - "heap_used=%lu, heap_free=%lu, bytes_since_gc=%lu, total_bytes=%lu", + SAPI::die("out of memory: failed to %s %u bytes. " + "heap_used=%u, heap_free=%u, bytes_since_gc=%u, total_bytes=%u", what, size, GC_get_heap_size(), GC_get_free_bytes(), @@ -30,8 +30,6 @@ void *pa_fail_alloc(const char* what, si #ifdef PA_DEBUG_GC_MEMORY -void bug() {} - const size_t HEADTAIL_SIZE=4; static size_t debug_size(size_t user_size) { @@ -62,17 +60,14 @@ static void* check_return_debug(void* au char* ptr=user_ptr-HEADTAIL_SIZE; size_t raw_size=GC_size(ptr); - if(raw_size==0) - bug(); + assert(raw_size!=0); size_t pure_size=raw_size; while(ptr[pure_size-1]==PAD_MARK) pure_size--; - if(memcmp(ptr, &BEFORE_MARK, HEADTAIL_SIZE)!=0) - bug(); - if(memcmp(ptr+pure_size-HEADTAIL_SIZE, &AFTER_MARK, HEADTAIL_SIZE)!=0) - bug(); + assert(memcmp(ptr, &BEFORE_MARK, HEADTAIL_SIZE)==0); + assert(memcmp(ptr+pure_size-HEADTAIL_SIZE, &AFTER_MARK, HEADTAIL_SIZE)==0); return ptr; } @@ -89,8 +84,8 @@ void* pa_gc_malloc_atomic(size_t size) { } void* pa_gc_realloc(void* user_ptr, size_t size) { - if(!GC_is_visible(user_ptr)) - bug(); + GC_is_visible(user_ptr); + //printf("realloc: 0x%p -> %u\n", ptr, size); size=debug_size(size); return fill_return_user(