--- parser3/src/include/pa_memory.h 2003/11/20 16:34:25 1.8 +++ parser3/src/include/pa_memory.h 2013/07/23 15:39:10 1.19 @@ -1,7 +1,7 @@ /** @file Parser: memory reference counting classes decls. - Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2012 Art. Lebedev Studio (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ @@ -9,34 +9,20 @@ #ifndef PA_MEMORY_H #define PA_MEMORY_H -static const char * const IDENT_MEMORY_H="$Date: 2003/11/20 16:34:25 $"; +#define IDENT_PA_MEMORY_H "$Id: pa_memory.h,v 1.19 2013/07/23 15:39:10 moko Exp $" // include #include "pa_config_includes.h" - -/// to debug backtrace pointers switch this on: -#ifdef _DEBUG -#define GC_DEBUG -#endif #include "gc.h" -// defines - -//#define PA_DEBUG_GC_MEMORY +// define destructors use for Array, Hash and VMethodFrame +#define USE_DESTRUCTORS -#ifdef PA_DEBUG_GC_MEMORY -void* pa_gc_malloc(size_t size); -void* pa_gc_malloc_atomic(size_t size); -void* pa_gc_realloc(void* ptr, size_t size); -void pa_gc_free(void* ptr); -#else inline void* pa_gc_malloc(size_t size) { return GC_MALLOC(size); } inline void* pa_gc_malloc_atomic(size_t size) { return GC_MALLOC_ATOMIC(size); } inline void* pa_gc_realloc(void* ptr, size_t size) { return GC_REALLOC(ptr, size); } inline void pa_gc_free(void* ptr) { GC_FREE(ptr); } -#endif - // forwards @@ -63,7 +49,7 @@ inline char *pa_strdup(const char* auto_ size_t size=known_length+1; if(char *result=static_cast(pa_gc_malloc_atomic(size))) { - memcpy(result, auto_variable_never_null, size); + memcpy(result, auto_variable_never_null, known_length); result[known_length]=0; return result; } @@ -82,9 +68,13 @@ inline void *pa_realloc(void *ptr, size_ return pa_fail_alloc("reallocate to", size); } -//{@ these operators are disabled, one should explicitely specify either new(UseGC) or new(PointerFreeGC) -inline void *operator new(size_t) { abort(); } // disabled -inline void *operator new[] (size_t) { abort(); } // disabled +//{@ these operators can be used from stl. to be on a safe side, assume that data may contain pointers +inline void *operator new[] (size_t size) { + return pa_malloc(size); +} +inline void *operator new(size_t size) { + return pa_malloc(size); +} //}@ #define UseGC ((int)1)