--- parser3/src/include/pa_memory.h 2009/04/18 00:33:34 1.17 +++ parser3/src/include/pa_memory.h 2013/07/23 15:47:07 1.20 @@ -1,7 +1,7 @@ /** @file Parser: memory reference counting classes decls. - Copyright (c) 2001-2009 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,32 +9,20 @@ #ifndef PA_MEMORY_H #define PA_MEMORY_H -static const char * const IDENT_MEMORY_H="$Date: 2009/04/18 00:33:34 $"; +#define IDENT_PA_MEMORY_H "$Id: pa_memory.h,v 1.20 2013/07/23 15:47:07 moko Exp $" // include #include "pa_config_includes.h" #include "gc.h" -// defines - -// use destructors for Array, Hash and VMethodFrame +// define destructors use for Array, Hash and VMethodFrame #define USE_DESTRUCTORS -//#define PA_DEBUG_GC_MEMORY - -#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 @@ -55,9 +43,10 @@ inline void *pa_malloc_atomic(size_t siz return pa_fail_alloc("allocate clean", size); } + /// @a length may be null, which mean "autocalc it" inline char *pa_strdup(const char* auto_variable_never_null, size_t helper_length=0) { - size_t known_length=(helper_length?helper_length:strlen(auto_variable_never_null)); + size_t known_length= helper_length ? helper_length : strlen(auto_variable_never_null); size_t size=known_length+1; if(char *result=static_cast(pa_gc_malloc_atomic(size))) {