--- parser3/src/include/pa_memory.h 2003/03/20 09:41:45 1.1.2.9.2.5 +++ parser3/src/include/pa_memory.h 2003/03/24 17:00:49 1.1.2.9.2.11 @@ -9,7 +9,7 @@ #ifndef PA_MEMORY_H #define PA_MEMORY_H -static const char* IDENT_MEMORY_H="$Date: 2003/03/20 09:41:45 $"; +static const char* IDENT_MEMORY_H="$Date: 2003/03/24 17:00:49 $"; #define PA_DEBUG_REFERENCES @@ -48,14 +48,18 @@ inline void *pa_malloc_atomic(size_t siz inline char *pa_strdup(const char* auto_variable_never_null, size_t length=0) { if(!length) length=strlen(auto_variable_never_null); - size_t size=length+1; // terminating zero + + size_t size=length+1; if(char *result=static_cast(GC_MALLOC_ATOMIC(size))) { - memcpy(result, auto_variable_never_null, size); + memcpy(result, auto_variable_never_null, length); + result[length]=0; return result; } return static_cast(pa_fail_alloc("allocate clean", size)); } +char* pa_format_integer(int value); + inline void pa_free(void *ptr) { GC_FREE(ptr); } @@ -67,23 +71,10 @@ inline void *pa_realloc(void *ptr, size_ return pa_fail_alloc("reallocate to", size); } -#define DECLARE_OBJECT_PTR(name) \ - typedef name* name##Ptr - -#define DECLARE_SMART_PTR(name) \ - typedef name* name##Ptr - -// defines - -#define override -#define rethrow throw - -// memory - //{@ these operators are disabled, one should explicitely specify either new(UseGC) or new(PointerFreeGC) -void *operator new(size_t size); // disabled, should cause link error! -void operator delete (void *ptr); // disabled, should cause link error! -void *operator new[] (size_t size); // disabled, should cause link error! +inline void *operator new(size_t size) { abort(); } // disabled +inline void operator delete (void *ptr) { abort(); } // disabled +inline void *operator new[] (size_t size) { abort(); } // disabled //}@ #define UseGC ((int)1) @@ -115,6 +106,9 @@ public: static void *malloc_atomic(size_t size) { return pa_malloc_atomic(size); } + static char *strdup(const char* auto_variable_never_null, size_t length=0) { + return pa_strdup(auto_variable_never_null, length); + } static void free(void *ptr) { pa_free(ptr); } @@ -124,7 +118,7 @@ public: private: // disabled from accidental use - /// use malloc instead [GC clears malloc result] + /// use malloc/malloc_atomic instead [GC clears result of those] static void *calloc(size_t size); }; @@ -132,6 +126,10 @@ private: // disabled from accidental use /// Base for all Parser classes typedef PA_Allocated PA_Object; -// convinient types +// defines + +#define override +#define rethrow throw + #endif