00001
00002
00003
00004
00005
00006
00007
00022 #ifndef OSCL_MEM_H_INCLUDED
00023 #define OSCL_MEM_H_INCLUDED
00024
00025 #ifndef OSCLCONFIG_MEMORY_H_INCLUDED
00026 #include "osclconfig_memory.h"
00027 #endif
00028
00029 #ifndef OSCL_BASE_H_INCLUDED
00030 #include "oscl_base.h"
00031 #endif
00032
00033 #ifndef OSCL_TYPES_H_INCLUDE
00034 #include "oscl_types.h"
00035 #endif
00036
00037 #ifndef OSCL_ASSERT_H_INCLUDED
00038 #include "oscl_assert.h"
00039 #endif
00040
00041 #ifndef OSCL_MEM_BASIC_FUNCTIONS_H
00042 #include "oscl_mem_basic_functions.h"
00043 #endif
00044
00045 #ifndef OSCL_LOCK_BASE_H_INCLUDED
00046 #include "oscl_lock_base.h"
00047 #endif
00048
00049 #define OSCL_DISABLE_WARNING_TRUNCATE_DEBUG_MESSAGE
00050 #include "osclconfig_compiler_warnings.h"
00051
00052 #ifndef OSCL_MEM_INST_H_INCLUDED
00053 #include "oscl_mem_inst.h"
00054 #endif
00055
00056 #ifndef OSCL_HEAPBASE_H_INCLUDED
00057 #include "oscl_heapbase.h"
00058 #endif
00059
00060
00061
00062 #ifndef OSCL_HAS_GLOBAL_NEW_DELETE
00063 #ifdef NDEBUG
00064
00065 #define OSCL_HAS_GLOBAL_NEW_DELETE 0
00066 #else
00067
00068 #define OSCL_HAS_GLOBAL_NEW_DELETE 1
00069 #endif //NDEBUG
00070 #endif //OSCL_HAS_GLOBAL_NEW_DELETE
00071
00072 class OsclMem
00073 {
00074 public:
00084 OSCL_IMPORT_REF static void Init();
00085
00089 OSCL_IMPORT_REF static void Cleanup();
00090
00091 };
00092
00093
00094
00095
00096 #include "oscl_base.h"
00097
00098
00099
00100
00101 #if (OSCL_BYPASS_MEMMGT)
00102
00103 class OsclAuditCB
00104 {
00105 public:
00106 };
00107 #else
00108 class OsclMemStatsNode;
00109 class OsclMemAudit;
00110 class OsclAuditCB
00111 {
00112 public:
00113 const OsclMemStatsNode* pStatsNode;
00114 OsclMemAudit *pAudit;
00115
00116 OsclAuditCB() :
00117 pStatsNode(NULL),
00118 pAudit(NULL)
00119 {}
00120
00121 OsclAuditCB(const OsclMemStatsNode* myStatsNode,
00122 OsclMemAudit *ptr)
00123 :
00124 pStatsNode(myStatsNode),
00125 pAudit(ptr)
00126 {
00127 }
00128 };
00129 #endif//OSCL_BYPASS_MEMMGT
00130
00138 OSCL_COND_IMPORT_REF uint oscl_mem_aligned_size(uint size);
00139
00147 OSCL_IMPORT_REF void OsclMemInit(OsclAuditCB & auditCB);
00148
00156 #define OSCL_CLEANUP_BASE_CLASS(T) _OSCL_CLEANUP_BASE_CLASS(T)
00157
00175 #if(OSCL_BYPASS_MEMMGT)
00176 #define OSCL_ALLOC_NEW(T_allocator, T, params) new(T_allocator.allocate(1)) T params
00177 #elif(PVMEM_INST_LEVEL>0)
00178 #define OSCL_ALLOC_NEW(T_allocator, T, params) new(T_allocator.allocate_fl(1,__FILE__,__LINE__)) T params
00179 #else
00180 #define OSCL_ALLOC_NEW(T_allocator, T, params) new(T_allocator.allocate(1)) T params
00181 #endif
00182
00204 #if(OSCL_BYPASS_MEMMGT)
00205 #define OSCL_TRAP_ALLOC_NEW(T_ptr,T_allocator,T,params) _OSCL_TRAP_NEW(T_allocator.allocate(1),T_allocator.deallocate,T_ptr,T,params)
00206 #elif(PVMEM_INST_LEVEL>0)
00207 #define OSCL_TRAP_ALLOC_NEW(T_ptr,T_allocator,T,params) _OSCL_TRAP_NEW(T_allocator.allocate_fl(1,__FILE__,__LINE__),T_allocator.deallocate,T_ptr,T,params)
00208 #else
00209 #define OSCL_TRAP_ALLOC_NEW(T_ptr,T_allocator,T,params) _OSCL_TRAP_NEW(T_allocator.allocate(1),T_allocator.deallocate,T_ptr,T,params)
00210 #endif
00211
00221 #define OSCL_ALLOC_DELETE(ptr, T_allocator, T) \
00222 {\
00223 ptr->~T();\
00224 T_allocator.deallocate(ptr);\
00225 }
00226
00227
00232
00233
00234 #if(!OSCL_BYPASS_MEMMGT)
00235 OSCL_IMPORT_REF void* _oscl_audit_malloc(size_t , OsclAuditCB & , const char * f = NULL, const int l = 0);
00236 OSCL_IMPORT_REF void* _oscl_audit_calloc(size_t , size_t, OsclAuditCB & , const char * f = NULL, const int l = 0);
00237 OSCL_IMPORT_REF void* _oscl_audit_realloc(void*, size_t , OsclAuditCB & , const char * f = NULL, const int l = 0);
00238 OSCL_IMPORT_REF void* _oscl_audit_new(size_t , OsclAuditCB & , const char * f = NULL, const int l = 0) ;
00239 OSCL_IMPORT_REF void* _oscl_default_audit_malloc(size_t , const char * f = NULL, const int l = 0);
00240 OSCL_IMPORT_REF void* _oscl_default_audit_calloc(size_t , size_t, const char * f = NULL, const int l = 0);
00241 OSCL_IMPORT_REF void* _oscl_default_audit_realloc(void*, size_t , const char * f = NULL, const int l = 0);
00242 OSCL_IMPORT_REF void* _oscl_default_audit_new(size_t , const char * f = NULL, const int l = 0) ;
00243 OSCL_IMPORT_REF void _oscl_audit_free(void *);
00244 #else
00245 OSCL_IMPORT_REF void* _oscl_default_new(size_t nBytes);
00246 #endif//OSCL_BYPASS_MEMMGT
00247
00248 #if (OSCL_HAS_GLOBAL_NEW_DELETE)
00249
00250
00251 #if(!OSCL_BYPASS_MEMMGT)
00252 inline void * operator new(size_t aSize, const char *aFile, int aLine)
00253 {
00254 #if(PVMEM_INST_LEVEL>0)
00255
00256 if (!aFile)
00257 return _oscl_default_audit_new(aSize, __FILE__, __LINE__);
00258 #endif
00259 return _oscl_default_audit_new(aSize, aFile, aLine);
00260 };
00261 #endif
00262
00263 inline void * operator new(size_t aSize)
00264 {
00265 #if(!OSCL_BYPASS_MEMMGT)
00266 #if(PVMEM_INST_LEVEL>0)
00267 return _oscl_default_audit_new(aSize, __FILE__, __LINE__);
00268 #else
00269 return _oscl_default_audit_new(aSize);
00270 #endif
00271 #else
00272 return _oscl_default_new(aSize);
00273 #endif
00274 };
00275
00276 inline void operator delete(void *aPtr)
00277 {
00278 #if(!OSCL_BYPASS_MEMMGT)
00279 _oscl_audit_free(aPtr);
00280 #else
00281 _oscl_free(aPtr);
00282 #endif
00283 };
00284
00285 #if(!OSCL_BYPASS_MEMMGT)
00286 inline void * operator new[](size_t aSize, const char *aFile, int aLine)
00287 {
00288 #if(PVMEM_INST_LEVEL>0)
00289
00290 if (!aFile)
00291 return _oscl_default_audit_new(aSize, __FILE__, __LINE__);
00292 #endif
00293 return _oscl_default_audit_new(aSize, aFile, aLine);
00294 };
00295 #endif
00296
00297 inline void * operator new[](size_t aSize)
00298 {
00299 #if(!OSCL_BYPASS_MEMMGT)
00300 #if(PVMEM_INST_LEVEL>0)
00301 return _oscl_default_audit_new(aSize, __FILE__, __LINE__);
00302 #else
00303 return _oscl_default_audit_new(aSize);
00304 #endif
00305 #else
00306 return _oscl_default_new(aSize);
00307 #endif
00308 };
00309
00310 inline void operator delete[](void *aPtr)
00311 {
00312 #if(!OSCL_BYPASS_MEMMGT)
00313 _oscl_audit_free(aPtr);
00314 #else
00315 _oscl_free(aPtr);
00316 #endif
00317 };
00318 #endif //OSCL_HAS_GLOBAL_NEW_DELETE
00319
00331 #if(OSCL_BYPASS_MEMMGT)
00332 #define OSCL_MALLOC(count) _oscl_malloc(count)
00333 #elif(PVMEM_INST_LEVEL>0)
00334 #define OSCL_MALLOC(count) _oscl_default_audit_malloc(count,__FILE__,__LINE__)
00335 #else
00336 #define OSCL_MALLOC(count) _oscl_default_audit_malloc(count)
00337 #endif
00338
00339
00340
00341
00342
00343
00344 #define oscl_malloc(a) OSCL_MALLOC(a)
00345
00349 #define OSCL_DEFAULT_MALLOC(x) OSCL_MALLOC(x)
00350
00362 #if(OSCL_BYPASS_MEMMGT)
00363 #define OSCL_AUDIT_MALLOC(auditCB, count) _oscl_malloc(count)
00364 #elif(PVMEM_INST_LEVEL>0)
00365 #define OSCL_AUDIT_MALLOC(auditCB, count) _oscl_audit_malloc(count, auditCB, __FILE__, __LINE__)
00366 #else
00367 #define OSCL_AUDIT_MALLOC(auditCB, count) _oscl_audit_malloc(count, auditCB)
00368 #endif
00369
00382 #if(OSCL_BYPASS_MEMMGT)
00383 #define OSCL_CALLOC(num,size) _oscl_calloc(num,size)
00384 #elif(PVMEM_INST_LEVEL>0)
00385 #define OSCL_CALLOC(num,size) _oscl_default_audit_calloc(num,size,__FILE__,__LINE__)
00386 #else
00387 #define OSCL_CALLOC(num,size) _oscl_default_audit_calloc(num,size)
00388 #endif
00389
00390
00391
00392
00393
00394
00395 #define oscl_calloc(a,b) OSCL_CALLOC(a,b)
00396
00410 #if(OSCL_BYPASS_MEMMGT)
00411 #define OSCL_AUDIT_CALLOC(auditCB, num,size) _oscl_calloc(num,size)
00412 #elif(PVMEM_INST_LEVEL>0)
00413 #define OSCL_AUDIT_CALLOC(auditCB, num,size) _oscl_audit_calloc(num,size, auditCB, __FILE__, __LINE__)
00414 #else
00415 #define OSCL_AUDIT_CALLOC(auditCB, num,size) _oscl_audit_calloc(num,size, auditCB)
00416 #endif
00417
00430 #if(OSCL_BYPASS_MEMMGT)
00431 #define OSCL_REALLOC(ptr,new_size) _oscl_realloc(ptr,new_size)
00432 #elif(PVMEM_INST_LEVEL>0)
00433 #define OSCL_REALLOC(ptr,new_size) _oscl_default_audit_realloc(ptr,new_size,__FILE__,__LINE__)
00434 #else
00435 #define OSCL_REALLOC(ptr,new_size) _oscl_default_audit_realloc(ptr,new_size)
00436 #endif
00437
00438
00439
00440
00441
00442
00443 #define oscl_realloc(a,b) OSCL_REALLOC(a,b)
00444
00458 #if(OSCL_BYPASS_MEMMGT)
00459 #define OSCL_AUDIT_REALLOC(auditCB, ptr,new_size) _oscl_realloc(ptr,new_size)
00460 #elif(PVMEM_INST_LEVEL>0)
00461 #define OSCL_AUDIT_REALLOC(auditCB, ptr,new_size) _oscl_audit_realloc(ptr,new_size, auditCB, __FILE__, __LINE__)
00462 #else
00463 #define OSCL_AUDIT_REALLOC(auditCB, ptr,new_size) _oscl_audit_realloc(ptr,new_size, auditCB)
00464 #endif
00465
00471 #if(OSCL_BYPASS_MEMMGT)
00472 #define OSCL_FREE(ptr) _oscl_free(ptr)
00473 #else
00474 #define OSCL_FREE(ptr) _oscl_audit_free(ptr)
00475 #endif
00476
00477
00478
00479
00480
00481
00482 #define oscl_free(x) OSCL_FREE(x)
00483
00487 #define OSCL_DEFAULT_FREE(x) OSCL_FREE(x)
00488
00506 #if(OSCL_BYPASS_MEMMGT)
00507 #define OSCL_NEW( T, params) new T params
00508 #elif!(OSCL_HAS_GLOBAL_NEW_DELETE)
00509 #define OSCL_NEW( T, params) new T params
00510 #elif(PVMEM_INST_LEVEL>0)
00511 #define OSCL_NEW( T, params) new(__FILE__,__LINE__) T params
00512 #else
00513 #define OSCL_NEW( T, params) new T params
00514 #endif
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524 #define OSCL_PLACEMENT_NEW(ptr, constructor) new(ptr) constructor
00525
00545 #if(OSCL_BYPASS_MEMMGT)
00546 #define OSCL_TRAP_NEW(T_ptr,T,params) _OSCL_TRAP_NEW(_oscl_default_new(sizeof(T)),_oscl_free,T_ptr,T,params)
00547 #elif!(OSCL_HAS_GLOBAL_NEW_DELETE)
00548 #define OSCL_TRAP_NEW(T_ptr,T,params) _OSCL_TRAP_NEW(_oscl_default_audit_new(sizeof(T)),_oscl_audit_free,T_ptr,T,params)
00549 #elif(PVMEM_INST_LEVEL>0)
00550 #define OSCL_TRAP_NEW(T_ptr,T,params) _OSCL_TRAP_NEW(_oscl_default_audit_new(sizeof(T),__FILE__,__LINE__),_oscl_audit_free,T_ptr,T,params)
00551 #else
00552 #define OSCL_TRAP_NEW(T_ptr,T,params) _OSCL_TRAP_NEW(_oscl_default_audit_new(sizeof(T)),_oscl_audit_free,T_ptr,T,params)
00553 #endif
00554
00555
00569 #if(OSCL_BYPASS_MEMMGT)
00570 #define OSCL_AUDIT_NEW(auditCB, T, params) new(_oscl_default_new(sizeof(T))) T params
00571 #elif!(OSCL_HAS_GLOBAL_NEW_DELETE)
00572 #define OSCL_AUDIT_NEW(auditCB, T, params) new(_oscl_audit_new(sizeof(T),auditCB)) T params
00573 #elif(PVMEM_INST_LEVEL>0)
00574 #define OSCL_AUDIT_NEW(auditCB, T, params) new(_oscl_audit_new(sizeof(T),auditCB,__FILE__,__LINE__)) T params
00575 #else
00576 #define OSCL_AUDIT_NEW(auditCB, T, params) new(_oscl_audit_new(sizeof(T),auditCB)) T params
00577 #endif
00578
00598 #if(OSCL_BYPASS_MEMMGT)
00599 #define OSCL_TRAP_AUDIT_NEW(T_ptr,auditCB,T,params) _OSCL_TRAP_NEW(_oscl_default_new(sizeof(T)),_oscl_free,T_ptr,T,params)
00600 #elif!(OSCL_HAS_GLOBAL_NEW_DELETE)
00601 #define OSCL_TRAP_AUDIT_NEW(T_ptr,auditCB,T,params) _OSCL_TRAP_NEW(_oscl_audit_new(sizeof(T),auditCB),_oscl_audit_free,T_ptr,T,params)
00602 #elif(PVMEM_INST_LEVEL>0)
00603 #define OSCL_TRAP_AUDIT_NEW(T_ptr,auditCB,T,params) _OSCL_TRAP_NEW(_oscl_audit_new(sizeof(T),auditCB,__FILE__,__LINE__),_oscl_audit_free,T_ptr,T,params)
00604 #else
00605 #define OSCL_TRAP_AUDIT_NEW(T_ptr,auditCB,T,params) _OSCL_TRAP_NEW(_oscl_audit_new(sizeof(T),auditCB),_oscl_audit_free,T_ptr,T,params)
00606 #endif
00607
00615 #define OSCL_DELETE(ptr) {\
00616 if(ptr){delete(ptr);}\
00617 }
00618
00619
00643 #if(OSCL_BYPASS_MEMMGT)
00644 #define OSCL_AUDIT_ARRAY_NEW(auditCB, T, count) new(_oscl_default_new(sizeof(T)*(count))) T
00645 #elif!(OSCL_HAS_GLOBAL_NEW_DELETE)
00646 #define OSCL_AUDIT_ARRAY_NEW(auditCB, T, count) new(_oscl_audit_new(sizeof(T)*(count),auditCB)) T
00647 #elif(PVMEM_INST_LEVEL>0)
00648 #define OSCL_AUDIT_ARRAY_NEW(auditCB, T, count) new(_oscl_audit_new(sizeof(T)*(count),auditCB,__FILE__,__LINE__)) T
00649 #else
00650 #define OSCL_AUDIT_ARRAY_NEW(auditCB, T, count) new(_oscl_audit_new(sizeof(T)*(count),auditCB)) T
00651 #endif
00652
00666 #if(OSCL_BYPASS_MEMMGT)
00667 #define OSCL_ARRAY_NEW(T, count) new T[count]
00668 #elif!(OSCL_HAS_GLOBAL_NEW_DELETE)
00669 #define OSCL_ARRAY_NEW(T, count) new T[count]
00670 #elif(PVMEM_INST_LEVEL>0)
00671 #define OSCL_ARRAY_NEW(T, count) new(__FILE__,__LINE__) T[count]
00672 #else
00673 #define OSCL_ARRAY_NEW(T, count) new T[count]
00674 #endif
00675
00683 #define OSCL_ARRAY_DELETE(ptr) delete [] ptr
00684
00685
00690 #ifndef OSCL_DEFALLOC_H_INCLUDED
00691 #include "oscl_defalloc.h"
00692 #endif
00693
00694 #ifndef OSCL_REFCOUNTER_H_INCLUDED
00695 #include "oscl_refcounter.h"
00696 #endif
00697
00698 #ifndef OSCL_MEM_BASIC_FUNCTIONS_H_INCLUDED
00699 #include "oscl_mem_basic_functions.h"
00700 #endif
00701
00702 #ifndef OSCL_ERROR_H_INCLUDED
00703 #include "oscl_error.h"
00704 #endif
00705
00706 #ifndef OSCL_EXCEPTION_H_INCLUDED
00707 #include "oscl_exception.h"
00708 #endif
00709
00710 #define OSCL_DISABLE_WARNING_TRUNCATE_DEBUG_MESSAGE
00711 #include "osclconfig_compiler_warnings.h"
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722 #ifdef OSCL_DISABLE_GCC_WARNING_SYSTEM_HEADER
00723 #pragma GCC system_header
00724 #endif
00725
00731 class OsclMemAllocator : public Oscl_DefAlloc
00732 {
00733 public:
00740 OsclAny* allocate(const uint32 n)
00741 {
00742 #if(OSCL_BYPASS_MEMMGT)
00743 OsclAny* p = _oscl_malloc(n);
00744 if (!p)
00745 OsclError::LeaveIfNull(p);
00746 #if OSCL_MEM_FILL_WITH_PATTERN
00747 oscl_memset(p, 0x55, n);
00748 #endif
00749 return (p);
00750 #elif (PVMEM_INST_LEVEL>0)
00751
00752
00753 return allocate_fl(n, __FILE__, __LINE__);
00754 #else
00755 return allocate_fl(n, NULL, 0);
00756 #endif
00757 }
00758
00759 #if(!OSCL_BYPASS_MEMMGT)
00760 OsclAny* allocate_fl(const uint32 n, const char * file_name, const int line_num)
00761 {
00762 OsclAny* p = _oscl_default_audit_malloc(n, file_name, line_num);
00763 if (!p)
00764 OsclError::LeaveIfNull(p);
00765 #if OSCL_MEM_FILL_WITH_PATTERN
00766 oscl_memset(p, 0x55, n);
00767 #endif
00768 return (p);
00769 }
00770 #endif
00771
00772 void deallocate(OsclAny* p)
00773 {
00774 if (p)
00775 OSCL_FREE(p);
00776 }
00777 };
00778
00779
00787 class OsclMemBasicAllocator : public Oscl_DefAlloc
00788 {
00789 public:
00796 OsclAny* allocate(const uint32 n)
00797 {
00798 OsclAny* p = _oscl_malloc(n);
00799 OsclError::LeaveIfNull(p);
00800 #if OSCL_MEM_FILL_WITH_PATTERN
00801 oscl_memset(p, 0x55, n);
00802 #endif
00803 return (p);
00804 }
00805
00806 void deallocate(OsclAny* p)
00807 {
00808 if (p)
00809 _oscl_free(p);
00810 }
00811 };
00812
00817 template <class T> class OsclMemAllocDestructDealloc : public OsclAllocDestructDealloc
00818 {
00819 public:
00820 #if !(OSCL_BYPASS_MEMMGT)
00821 OsclAny* allocate_fl(const uint32 size, const char * file_name, const int line_num)
00822 {
00823 return alloc.allocate_fl(size, file_name, line_num);
00824 }
00825 #endif
00826 OsclAny* allocate(const uint32 size)
00827 {
00828 #if(OSCL_BYPASS_MEMMGT)
00829 return alloc.allocate(size);
00830 #elif(PVMEM_INST_LEVEL>0)
00831
00832
00833 return allocate_fl(size, __FILE__, __LINE__);
00834 #else
00835 return allocate_fl(size, NULL, 0);
00836 #endif
00837 }
00838 void deallocate(OsclAny* p)
00839 {
00840 alloc.deallocate(p);
00841 }
00842 void destruct_and_dealloc(OsclAny* p)
00843 {
00844 T* ptr = reinterpret_cast<T*>(p);
00845 ptr->~T();
00846 deallocate(p);
00847 OSCL_UNUSED_ARG(ptr);
00848 }
00849 private:
00850 OsclMemAllocator alloc;
00851 };
00852
00857 template <class T> class OsclMemBasicAllocDestructDealloc : public OsclAllocDestructDealloc
00858 {
00859 public:
00860 OsclAny* allocate(const uint32 size)
00861 {
00862 #if(OSCL_BYPASS_MEMMGT)
00863 return alloc.allocate(size);
00864 #else
00865 return alloc.allocate_fl(size, NULL, 0);
00866 #endif
00867 }
00868 void deallocate(OsclAny* p)
00869 {
00870 alloc.deallocate(p);
00871 }
00872 void destruct_and_dealloc(OsclAny* p)
00873 {
00874 T* ptr = reinterpret_cast<T*>(p);
00875 ptr->~T();
00876 deallocate(p);
00877 OSCL_UNUSED_ARG(ptr);
00878 }
00879 private:
00880 OsclMemBasicAllocator alloc;
00881 };
00882
00887 class OsclMemAudit;
00888 class OsclMemGlobalAuditObject
00889 {
00890 public:
00891 typedef OsclMemAudit audit_type;
00896 OSCL_IMPORT_REF static audit_type* getGlobalMemAuditObject();
00897
00898 private:
00902 static void createGlobalMemAuditObject();
00903
00907 static void deleteGlobalMemAuditObject();
00908
00909 friend class OsclMem;
00910 };
00911
00923 class HeapBase : public _OsclHeapBase
00924 {
00925 public:
00926 #if (OSCL_HAS_HEAP_BASE_SUPPORT)
00927
00928 #if(!OSCL_BYPASS_MEMMGT)
00929 static void* operator new(size_t aSize, const char *aFile = NULL, const int aLine = 0)
00930 {
00931 #if(PVMEM_INST_LEVEL>0)
00932
00933 if (!aFile)
00934 return _oscl_default_audit_new(aSize, __FILE__, __LINE__);
00935 #endif
00936 return _oscl_default_audit_new(aSize, aFile, aLine);
00937 }
00938 #else
00939 static void* operator new(size_t aSize)
00940 {
00941 return _oscl_default_new(aSize);
00942 }
00943 #endif
00944
00945 static void* operator new[](size_t aSize)
00946 {
00947 #if(!OSCL_BYPASS_MEMMGT)
00948 return _oscl_default_audit_new(aSize);
00949 #else
00950 return _oscl_default_new(aSize);
00951 #endif
00952 }
00953
00954 static void* operator new[](size_t aSize, const char *aFile = NULL, const int aLine = 0)
00955 {
00956 #if(!OSCL_BYPASS_MEMMGT)
00957 #if(PVMEM_INST_LEVEL>0)
00958
00959 if (!aFile)
00960 return _oscl_default_audit_new(aSize, __FILE__, __LINE__);
00961 #endif
00962 return _oscl_default_audit_new(aSize, aFile, aLine);
00963 #else
00964 OSCL_UNUSED_ARG(aFile);
00965 OSCL_UNUSED_ARG(aLine);
00966 return _oscl_default_new(aSize);
00967 #endif
00968 }
00969
00970 static void* operator new(size_t aSize, void *aPtr)
00971 {
00972 return aPtr;
00973 }
00974
00975 static void operator delete(void* aPtr)
00976 {
00977 #if(!OSCL_BYPASS_MEMMGT)
00978 _oscl_audit_free(aPtr);
00979 #else
00980 _oscl_free(aPtr);
00981 #endif
00982 }
00983
00984 static void operator delete[](void* aPtr)
00985 {
00986 #if(!OSCL_BYPASS_MEMMGT)
00987 _oscl_audit_free(aPtr);
00988 #else
00989 _oscl_free(aPtr);
00990 #endif
00991 }
00992 #endif //OSCL_HAS_HEAP_BASE_SUPPORT
00993 HeapBase() {};
00994 virtual ~HeapBase() {};
00995 };
00996
01013 #define _OSCL_TRAP_NEW(exp,freeFunc,T_ptr,T,params)\
01014 {\
01015 int32 __err;\
01016 OsclAny*__ptr=exp;\
01017 OSCL_TRY(__err,T_ptr=new(__ptr) T params;);\
01018 if(__err){\
01019 freeFunc(__ptr);\
01020 T_ptr=NULL;\
01021 OsclError::Leave(__err);\
01022 }\
01023 }
01024
01032 #ifdef PVERROR_IMP_CPP_EXCEPTIONS
01033
01034 #define _OSCL_CLEANUP_BASE_CLASS(T)
01035 #else
01036
01037 #define _OSCL_CLEANUP_BASE_CLASS(T) this->T::~T()
01038 #endif
01039
01040
01044 #if (!OSCL_DISABLE_INLINES)
01045 #include "oscl_mem.inl"
01046 #endif
01047
01048 #endif // OSCL_MEM_H_INCLUDED
01049
01050
01051