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 #if (OSCL_RELEASE_BUILD)
00064
00065 #define OSCL_HAS_GLOBAL_NEW_DELETE 0
00066 #else
00067
00068 #define OSCL_HAS_GLOBAL_NEW_DELETE 1
00069 #endif //OSCL_RELEASE_BUILD
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
00718 class OsclMemAllocator : public Oscl_DefAlloc
00719 {
00720 public:
00727 OsclAny* allocate(const uint32 n)
00728 {
00729 #if(OSCL_BYPASS_MEMMGT)
00730 OsclAny* p = _oscl_malloc(n);
00731 if (!p)
00732 OsclError::LeaveIfNull(p);
00733 #if OSCL_MEM_FILL_WITH_PATTERN
00734 oscl_memset(p, 0x55, n);
00735 #endif
00736 return (p);
00737 #elif (PVMEM_INST_LEVEL>0)
00738
00739
00740 return allocate_fl(n, __FILE__, __LINE__);
00741 #else
00742 return allocate_fl(n, NULL, 0);
00743 #endif
00744 }
00745
00746 #if(!OSCL_BYPASS_MEMMGT)
00747 OsclAny* allocate_fl(const uint32 n, const char * file_name, const int line_num)
00748 {
00749 OsclAny* p = _oscl_default_audit_malloc(n, file_name, line_num);
00750 if (!p)
00751 OsclError::LeaveIfNull(p);
00752 #if OSCL_MEM_FILL_WITH_PATTERN
00753 oscl_memset(p, 0x55, n);
00754 #endif
00755 return (p);
00756 }
00757 #endif
00758
00759 void deallocate(OsclAny* p)
00760 {
00761 if (p)
00762 OSCL_FREE(p);
00763 }
00764 };
00765
00766
00774 class OsclMemBasicAllocator : public Oscl_DefAlloc
00775 {
00776 public:
00783 OsclAny* allocate(const uint32 n)
00784 {
00785 OsclAny* p = _oscl_malloc(n);
00786 OsclError::LeaveIfNull(p);
00787 #if OSCL_MEM_FILL_WITH_PATTERN
00788 oscl_memset(p, 0x55, n);
00789 #endif
00790 return (p);
00791 }
00792
00793 void deallocate(OsclAny* p)
00794 {
00795 if (p)
00796 _oscl_free(p);
00797 }
00798 };
00799
00804 template <class T> class OsclMemAllocDestructDealloc : public OsclAllocDestructDealloc
00805 {
00806 public:
00807 #if !(OSCL_BYPASS_MEMMGT)
00808 OsclAny* allocate_fl(const uint32 size, const char * file_name, const int line_num)
00809 {
00810 return alloc.allocate_fl(size, file_name, line_num);
00811 }
00812 #endif
00813 OsclAny* allocate(const uint32 size)
00814 {
00815 #if(OSCL_BYPASS_MEMMGT)
00816 return alloc.allocate(size);
00817 #elif(PVMEM_INST_LEVEL>0)
00818
00819
00820 return allocate_fl(size, __FILE__, __LINE__);
00821 #else
00822 return allocate_fl(size, NULL, 0);
00823 #endif
00824 }
00825 void deallocate(OsclAny* p)
00826 {
00827 alloc.deallocate(p);
00828 }
00829 void destruct_and_dealloc(OsclAny* p)
00830 {
00831 T* ptr = reinterpret_cast<T*>(p);
00832 ptr->~T();
00833 deallocate(p);
00834 OSCL_UNUSED_ARG(ptr);
00835 }
00836 private:
00837 OsclMemAllocator alloc;
00838 };
00839
00844 template <class T> class OsclMemBasicAllocDestructDealloc : public OsclAllocDestructDealloc
00845 {
00846 public:
00847 OsclAny* allocate(const uint32 size)
00848 {
00849 #if(OSCL_BYPASS_MEMMGT)
00850 return alloc.allocate(size);
00851 #else
00852 return alloc.allocate_fl(size, NULL, 0);
00853 #endif
00854 }
00855 void deallocate(OsclAny* p)
00856 {
00857 alloc.deallocate(p);
00858 }
00859 void destruct_and_dealloc(OsclAny* p)
00860 {
00861 T* ptr = reinterpret_cast<T*>(p);
00862 ptr->~T();
00863 deallocate(p);
00864 OSCL_UNUSED_ARG(ptr);
00865 }
00866 private:
00867 OsclMemBasicAllocator alloc;
00868 };
00869
00874 class OsclMemAudit;
00875 class OsclMemGlobalAuditObject
00876 {
00877 public:
00878 typedef OsclMemAudit audit_type;
00883 OSCL_IMPORT_REF static audit_type* getGlobalMemAuditObject();
00884
00885 private:
00889 static void createGlobalMemAuditObject();
00890
00894 static void deleteGlobalMemAuditObject();
00895
00896 friend class OsclMem;
00897 };
00898
00910 class HeapBase : public _OsclHeapBase
00911 {
00912 public:
00913 #if (OSCL_HAS_HEAP_BASE_SUPPORT)
00914
00915 #if(!OSCL_BYPASS_MEMMGT)
00916 static void* operator new(size_t aSize, const char *aFile = NULL, const int aLine = 0)
00917 {
00918 #if(PVMEM_INST_LEVEL>0)
00919
00920 if (!aFile)
00921 return _oscl_default_audit_new(aSize, __FILE__, __LINE__);
00922 #endif
00923 return _oscl_default_audit_new(aSize, aFile, aLine);
00924 }
00925 #else
00926 static void* operator new(size_t aSize)
00927 {
00928 return _oscl_default_new(aSize);
00929 }
00930 #endif
00931
00932 static void* operator new[](size_t aSize)
00933 {
00934 #if(!OSCL_BYPASS_MEMMGT)
00935 return _oscl_default_audit_new(aSize);
00936 #else
00937 return _oscl_default_new(aSize);
00938 #endif
00939 }
00940
00941 static void* operator new[](size_t aSize, const char *aFile = NULL, const int aLine = 0)
00942 {
00943 #if(!OSCL_BYPASS_MEMMGT)
00944 #if(PVMEM_INST_LEVEL>0)
00945
00946 if (!aFile)
00947 return _oscl_default_audit_new(aSize, __FILE__, __LINE__);
00948 #endif
00949 return _oscl_default_audit_new(aSize, aFile, aLine);
00950 #else
00951 OSCL_UNUSED_ARG(aFile);
00952 OSCL_UNUSED_ARG(aLine);
00953 return _oscl_default_new(aSize);
00954 #endif
00955 }
00956
00957 static void* operator new(size_t aSize, void *aPtr)
00958 {
00959 return aPtr;
00960 }
00961
00962 static void operator delete(void* aPtr)
00963 {
00964 #if(!OSCL_BYPASS_MEMMGT)
00965 _oscl_audit_free(aPtr);
00966 #else
00967 _oscl_free(aPtr);
00968 #endif
00969 }
00970
00971 static void operator delete[](void* aPtr)
00972 {
00973 #if(!OSCL_BYPASS_MEMMGT)
00974 _oscl_audit_free(aPtr);
00975 #else
00976 _oscl_free(aPtr);
00977 #endif
00978 }
00979 #endif //OSCL_HAS_HEAP_BASE_SUPPORT
00980 HeapBase() {};
00981 virtual ~HeapBase() {};
00982 };
00983
01000 #define _OSCL_TRAP_NEW(exp,freeFunc,T_ptr,T,params)\
01001 {\
01002 int32 __err;\
01003 OsclAny*__ptr=exp;\
01004 OSCL_TRY(__err,T_ptr=new(__ptr) T params;);\
01005 if(__err){\
01006 freeFunc(__ptr);\
01007 T_ptr=NULL;\
01008 OsclError::Leave(__err);\
01009 }\
01010 }
01011
01019 #ifdef PVERROR_IMP_CPP_EXCEPTIONS
01020
01021 #define _OSCL_CLEANUP_BASE_CLASS(T)
01022 #else
01023
01024 #define _OSCL_CLEANUP_BASE_CLASS(T) this->T::~T()
01025 #endif
01026
01027
01031 #if (!OSCL_DISABLE_INLINES)
01032 #include "oscl_mem.inl"
01033 #endif
01034
01035 #endif // OSCL_MEM_H_INCLUDED
01036
01037
01038