1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> 3 <title>oscl_mem.h Source File</title> 4 <link href="doxygen.css" rel="stylesheet" type="text/css"> 5 </head><body> 6 <!-- Generated by Doxygen 1.2.18 --> 7 <center> 8 <a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="modules.html">Modules</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Data Structures</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Data Fields</a> <a class="qindex" href="globals.html">Globals</a> </center> 9 <hr><h1>oscl_mem.h</h1><a href="oscl__mem_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">// -*- c++ -*-</span> 10 00002 <span class="comment">// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</span> 11 00003 12 00004 <span class="comment">// O S C L _ M E M</span> 13 00005 14 00006 <span class="comment">// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</span> 15 00007 16 00022 <span class="preprocessor">#ifndef OSCL_MEM_H_INCLUDED</span> 17 00023 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_MEM_H_INCLUDED</span> 18 00024 <span class="preprocessor"></span> 19 00025 <span class="preprocessor">#ifndef OSCLCONFIG_MEMORY_H_INCLUDED</span> 20 00026 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="osclconfig__memory_8h.html">osclconfig_memory.h</a>"</span> 21 00027 <span class="preprocessor">#endif</span> 22 00028 <span class="preprocessor"></span> 23 00029 <span class="preprocessor">#ifndef OSCL_BASE_H_INCLUDED</span> 24 00030 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__base_8h.html">oscl_base.h</a>"</span> 25 00031 <span class="preprocessor">#endif</span> 26 00032 <span class="preprocessor"></span> 27 00033 <span class="preprocessor">#ifndef OSCL_TYPES_H_INCLUDE</span> 28 00034 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__types_8h.html">oscl_types.h</a>"</span> 29 00035 <span class="preprocessor">#endif</span> 30 00036 <span class="preprocessor"></span> 31 00037 <span class="preprocessor">#ifndef OSCL_ASSERT_H_INCLUDED</span> 32 00038 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__assert_8h.html">oscl_assert.h</a>"</span> 33 00039 <span class="preprocessor">#endif</span> 34 00040 <span class="preprocessor"></span> 35 00041 <span class="preprocessor">#ifndef OSCL_MEM_BASIC_FUNCTIONS_H</span> 36 00042 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__mem__basic__functions_8h.html">oscl_mem_basic_functions.h</a>"</span> 37 00043 <span class="preprocessor">#endif</span> 38 00044 <span class="preprocessor"></span> 39 00045 <span class="preprocessor">#ifndef OSCL_LOCK_BASE_H_INCLUDED</span> 40 00046 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__lock__base_8h.html">oscl_lock_base.h</a>"</span> 41 00047 <span class="preprocessor">#endif</span> 42 00048 <span class="preprocessor"></span> 43 00049 <span class="preprocessor">#define OSCL_DISABLE_WARNING_TRUNCATE_DEBUG_MESSAGE</span> 44 00050 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="osclconfig__compiler__warnings_8h.html">osclconfig_compiler_warnings.h</a>"</span> 45 00051 46 00052 <span class="preprocessor">#ifndef OSCL_MEM_INST_H_INCLUDED</span> 47 00053 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__mem__inst_8h.html">oscl_mem_inst.h</a>"</span> 48 00054 <span class="preprocessor">#endif</span> 49 00055 <span class="preprocessor"></span> 50 00056 <span class="preprocessor">#ifndef OSCL_HEAPBASE_H_INCLUDED</span> 51 00057 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__heapbase_8h.html">oscl_heapbase.h</a>"</span> 52 00058 <span class="preprocessor">#endif</span> 53 00059 <span class="preprocessor"></span> 54 00060 <span class="comment">//Default for OSCL_HAS_GLOBAL_NEW_DELETE in case it is *not* defined</span> 55 00061 <span class="comment">//in the osclconfig_memory.h</span> 56 00062 <span class="preprocessor">#ifndef OSCL_HAS_GLOBAL_NEW_DELETE</span> 57 00063 <span class="preprocessor"></span><span class="preprocessor">#ifdef NDEBUG</span> 58 00064 <span class="preprocessor"></span><span class="comment">//Release Mode - No definition for global new and delete.</span> 59 00065 <span class="preprocessor">#define OSCL_HAS_GLOBAL_NEW_DELETE 0</span> 60 00066 <span class="preprocessor"></span><span class="preprocessor">#else</span> 61 00067 <span class="preprocessor"></span><span class="comment">//Debug Mode - Define global new and delete.</span> 62 <a name="l00068"></a><a class="code" href="group__osclmemory.html#a34">00068</a> <span class="preprocessor">#define OSCL_HAS_GLOBAL_NEW_DELETE 1</span> 63 00069 <span class="preprocessor"></span><span class="preprocessor">#endif //NDEBUG</span> 64 00070 <span class="preprocessor"></span><span class="preprocessor">#endif //OSCL_HAS_GLOBAL_NEW_DELETE</span> 65 00071 <span class="preprocessor"></span> 66 <a name="l00072"></a><a class="code" href="classOsclMem.html">00072</a> <span class="keyword">class </span><a class="code" href="classOsclMem.html">OsclMem</a> 67 00073 { 68 00074 <span class="keyword">public</span>: 69 00084 OSCL_IMPORT_REF <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classOsclMem.html#d0">Init</a>(); 70 00085 71 00089 OSCL_IMPORT_REF <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classOsclMem.html#d1">Cleanup</a>(); 72 00090 73 00091 }; 74 00092 75 00093 <span class="comment">/*</span> 76 00094 <span class="comment">** Choose whether to use per-thread or singleton registry for auditing</span> 77 00095 <span class="comment">*/</span> 78 00096 <span class="preprocessor">#include "<a class="code" href="oscl__base_8h.html">oscl_base.h</a>"</span> 79 00097 80 00098 <span class="comment">/*</span> 81 00099 <span class="comment">** Audit control block</span> 82 00100 <span class="comment">*/</span> 83 00101 <span class="preprocessor">#if (OSCL_BYPASS_MEMMGT)</span> 84 00102 <span class="preprocessor"></span><span class="comment">//empty class for compilation only</span> 85 00103 <span class="keyword">class </span><a class="code" href="classOsclAuditCB.html">OsclAuditCB</a> 86 00104 { 87 00105 <span class="keyword">public</span>: 88 00106 }; 89 00107 <span class="preprocessor">#else</span> 90 00108 <span class="preprocessor"></span><span class="keyword">class </span><a class="code" href="classOsclMemStatsNode.html">OsclMemStatsNode</a>; 91 00109 <span class="keyword">class </span><a class="code" href="classOsclMemAudit.html">OsclMemAudit</a>; 92 <a name="l00110"></a><a class="code" href="classOsclAuditCB.html">00110</a> <span class="keyword">class </span><a class="code" href="classOsclAuditCB.html">OsclAuditCB</a> 93 00111 { 94 00112 <span class="keyword">public</span>: 95 <a name="l00113"></a><a class="code" href="classOsclAuditCB.html#m0">00113</a> <span class="keyword">const</span> <a class="code" href="classOsclMemStatsNode.html">OsclMemStatsNode</a>* <a class="code" href="classOsclAuditCB.html#m0">pStatsNode</a>; 96 <a name="l00114"></a><a class="code" href="classOsclAuditCB.html#m1">00114</a> <a class="code" href="classOsclMemAudit.html">OsclMemAudit</a> *<a class="code" href="classOsclAuditCB.html#m1">pAudit</a>; 97 00115 98 <a name="l00116"></a><a class="code" href="classOsclAuditCB.html#a0">00116</a> <a class="code" href="classOsclAuditCB.html#a0">OsclAuditCB</a>() : 99 00117 pStatsNode(<a class="code" href="group__osclbase.html#a81">NULL</a>), 100 00118 pAudit(<a class="code" href="group__osclbase.html#a81">NULL</a>) 101 00119 {} 102 00120 103 <a name="l00121"></a><a class="code" href="classOsclAuditCB.html#a1">00121</a> <a class="code" href="classOsclAuditCB.html#a0">OsclAuditCB</a>(<span class="keyword">const</span> <a class="code" href="classOsclMemStatsNode.html">OsclMemStatsNode</a>* myStatsNode, 104 00122 <a class="code" href="classOsclMemAudit.html">OsclMemAudit</a> *ptr) 105 00123 : 106 00124 pStatsNode(myStatsNode), 107 00125 pAudit(ptr) 108 00126 { 109 00127 } 110 00128 }; 111 00129 <span class="preprocessor">#endif//OSCL_BYPASS_MEMMGT</span> 112 00130 <span class="preprocessor"></span> 113 00138 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="group__osclbase.html#a27">uint</a> <a class="code" href="group__osclmemory.html#a16">oscl_mem_aligned_size</a>(<a class="code" href="group__osclbase.html#a27">uint</a> size); 114 00139 115 00147 OSCL_IMPORT_REF <span class="keywordtype">void</span> <a class="code" href="group__osclmemory.html#a17">OsclMemInit</a>(<a class="code" href="classOsclAuditCB.html">OsclAuditCB</a> & auditCB); 116 00148 117 <a name="l00156"></a><a class="code" href="group__osclmemory.html#a35">00156</a> <span class="preprocessor">#define OSCL_CLEANUP_BASE_CLASS(T) _OSCL_CLEANUP_BASE_CLASS(T)</span> 118 00157 <span class="preprocessor"></span> 119 00175 <span class="preprocessor">#if(OSCL_BYPASS_MEMMGT)</span> 120 00176 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_ALLOC_NEW(T_allocator, T, params) new(T_allocator.allocate(1)) T params</span> 121 00177 <span class="preprocessor"></span><span class="preprocessor">#elif(PVMEM_INST_LEVEL>0)</span> 122 00178 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_ALLOC_NEW(T_allocator, T, params) new(T_allocator.allocate_fl(1,__FILE__,__LINE__)) T params</span> 123 00179 <span class="preprocessor"></span><span class="preprocessor">#else</span> 124 <a name="l00180"></a><a class="code" href="group__osclmemory.html#a36">00180</a> <span class="preprocessor"></span><span class="preprocessor">#define OSCL_ALLOC_NEW(T_allocator, T, params) new(T_allocator.allocate(1)) T params</span> 125 00181 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 126 00182 <span class="preprocessor"></span> 127 00204 <span class="preprocessor">#if(OSCL_BYPASS_MEMMGT)</span> 128 00205 <span class="preprocessor"></span><span class="preprocessor">#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)</span> 129 00206 <span class="preprocessor"></span><span class="preprocessor">#elif(PVMEM_INST_LEVEL>0)</span> 130 00207 <span class="preprocessor"></span><span class="preprocessor">#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)</span> 131 00208 <span class="preprocessor"></span><span class="preprocessor">#else</span> 132 <a name="l00209"></a><a class="code" href="group__osclmemory.html#a37">00209</a> <span class="preprocessor"></span><span class="preprocessor">#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)</span> 133 00210 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 134 00211 <span class="preprocessor"></span> 135 <a name="l00221"></a><a class="code" href="group__osclmemory.html#a38">00221</a> <span class="preprocessor">#define OSCL_ALLOC_DELETE(ptr, T_allocator, T) \</span> 136 00222 <span class="preprocessor"> {\</span> 137 00223 <span class="preprocessor"> ptr->~T();\</span> 138 00224 <span class="preprocessor"> T_allocator.deallocate(ptr);\</span> 139 00225 <span class="preprocessor"> }</span> 140 00226 <span class="preprocessor"></span> 141 00227 142 00232 <span class="comment">//These are for internal use but need to be visible since they're used</span> 143 00233 <span class="comment">//in macros.</span> 144 00234 <span class="preprocessor">#if(!OSCL_BYPASS_MEMMGT)</span> 145 00235 <span class="preprocessor"></span>OSCL_IMPORT_REF <span class="keywordtype">void</span>* <a class="code" href="group__osclmemory.html#a18">_oscl_audit_malloc</a>(size_t , <a class="code" href="classOsclAuditCB.html">OsclAuditCB</a> & , <span class="keyword">const</span> <span class="keywordtype">char</span> * f = <a class="code" href="group__osclbase.html#a81">NULL</a>, <span class="keyword">const</span> <span class="keywordtype">int</span> l = 0); 146 00236 OSCL_IMPORT_REF <span class="keywordtype">void</span>* <a class="code" href="group__osclmemory.html#a19">_oscl_audit_calloc</a>(size_t , size_t, <a class="code" href="classOsclAuditCB.html">OsclAuditCB</a> & , <span class="keyword">const</span> <span class="keywordtype">char</span> * f = <a class="code" href="group__osclbase.html#a81">NULL</a>, <span class="keyword">const</span> <span class="keywordtype">int</span> l = 0); 147 00237 OSCL_IMPORT_REF <span class="keywordtype">void</span>* <a class="code" href="group__osclmemory.html#a20">_oscl_audit_realloc</a>(<span class="keywordtype">void</span>*, size_t , <a class="code" href="classOsclAuditCB.html">OsclAuditCB</a> & , <span class="keyword">const</span> <span class="keywordtype">char</span> * f = <a class="code" href="group__osclbase.html#a81">NULL</a>, <span class="keyword">const</span> <span class="keywordtype">int</span> l = 0); 148 00238 OSCL_IMPORT_REF <span class="keywordtype">void</span>* <a class="code" href="group__osclmemory.html#a21">_oscl_audit_new</a>(size_t , <a class="code" href="classOsclAuditCB.html">OsclAuditCB</a> & , <span class="keyword">const</span> <span class="keywordtype">char</span> * f = <a class="code" href="group__osclbase.html#a81">NULL</a>, <span class="keyword">const</span> <span class="keywordtype">int</span> l = 0) ; 149 00239 OSCL_IMPORT_REF <span class="keywordtype">void</span>* <a class="code" href="group__osclmemory.html#a22">_oscl_default_audit_malloc</a>(size_t , <span class="keyword">const</span> <span class="keywordtype">char</span> * f = <a class="code" href="group__osclbase.html#a81">NULL</a>, <span class="keyword">const</span> <span class="keywordtype">int</span> l = 0); 150 00240 OSCL_IMPORT_REF <span class="keywordtype">void</span>* <a class="code" href="group__osclmemory.html#a23">_oscl_default_audit_calloc</a>(size_t , size_t, <span class="keyword">const</span> <span class="keywordtype">char</span> * f = <a class="code" href="group__osclbase.html#a81">NULL</a>, <span class="keyword">const</span> <span class="keywordtype">int</span> l = 0); 151 00241 OSCL_IMPORT_REF <span class="keywordtype">void</span>* <a class="code" href="group__osclmemory.html#a24">_oscl_default_audit_realloc</a>(<span class="keywordtype">void</span>*, size_t , <span class="keyword">const</span> <span class="keywordtype">char</span> * f = <a class="code" href="group__osclbase.html#a81">NULL</a>, <span class="keyword">const</span> <span class="keywordtype">int</span> l = 0); 152 00242 OSCL_IMPORT_REF <span class="keywordtype">void</span>* <a class="code" href="group__osclmemory.html#a25">_oscl_default_audit_new</a>(size_t , <span class="keyword">const</span> <span class="keywordtype">char</span> * f = <a class="code" href="group__osclbase.html#a81">NULL</a>, <span class="keyword">const</span> <span class="keywordtype">int</span> l = 0) ; 153 00243 OSCL_IMPORT_REF <span class="keywordtype">void</span> <a class="code" href="group__osclmemory.html#a26">_oscl_audit_free</a>(<span class="keywordtype">void</span> *); 154 00244 <span class="preprocessor">#else</span> 155 00245 <span class="preprocessor"></span>OSCL_IMPORT_REF <span class="keywordtype">void</span>* _oscl_default_new(size_t nBytes); 156 00246 <span class="preprocessor">#endif//OSCL_BYPASS_MEMMGT</span> 157 00247 <span class="preprocessor"></span> 158 00248 <span class="preprocessor">#if (OSCL_HAS_GLOBAL_NEW_DELETE)</span> 159 00249 <span class="preprocessor"></span><span class="comment">//Global New operator overloaded to check native new operators called</span> 160 00250 161 00251 <span class="preprocessor">#if(!OSCL_BYPASS_MEMMGT)</span> 162 <a name="l00252"></a><a class="code" href="group__osclmemory.html#a27">00252</a> <span class="preprocessor"></span><span class="keyword">inline</span> <span class="keywordtype">void</span> * <a class="code" href="oscl__mem_8h.html#a43">operator new</a>(size_t aSize, <span class="keyword">const</span> <span class="keywordtype">char</span> *aFile, <span class="keywordtype">int</span> aLine) 163 00253 { 164 00254 <span class="preprocessor">#if(PVMEM_INST_LEVEL>0)</span> 165 00255 <span class="preprocessor"></span> <span class="comment">//in case NULL is passed in, record this file & line #</span> 166 00256 <span class="keywordflow">if</span> (!aFile) 167 00257 <span class="keywordflow">return</span> <a class="code" href="group__osclmemory.html#a25">_oscl_default_audit_new</a>(aSize, __FILE__, __LINE__); 168 00258 <span class="preprocessor">#endif</span> 169 00259 <span class="preprocessor"></span> <span class="keywordflow">return</span> <a class="code" href="group__osclmemory.html#a25">_oscl_default_audit_new</a>(aSize, aFile, aLine); 170 00260 }; 171 00261 <span class="preprocessor">#endif</span> 172 00262 <span class="preprocessor"></span> 173 <a name="l00263"></a><a class="code" href="oscl__mem_8h.html#a43">00263</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> * <a class="code" href="oscl__mem_8h.html#a43">operator new</a>(size_t aSize) 174 00264 { 175 00265 <span class="preprocessor">#if(!OSCL_BYPASS_MEMMGT)</span> 176 00266 <span class="preprocessor"></span><span class="preprocessor">#if(PVMEM_INST_LEVEL>0)</span> 177 00267 <span class="preprocessor"></span> <span class="keywordflow">return</span> <a class="code" href="group__osclmemory.html#a25">_oscl_default_audit_new</a>(aSize, __FILE__, __LINE__); 178 00268 <span class="preprocessor">#else</span> 179 00269 <span class="preprocessor"></span> <span class="keywordflow">return</span> <a class="code" href="group__osclmemory.html#a25">_oscl_default_audit_new</a>(aSize); 180 00270 <span class="preprocessor">#endif</span> 181 00271 <span class="preprocessor"></span><span class="preprocessor">#else</span> 182 00272 <span class="preprocessor"></span> <span class="keywordflow">return</span> _oscl_default_new(aSize); 183 00273 <span class="preprocessor">#endif</span> 184 00274 <span class="preprocessor"></span>}; 185 00275 186 <a name="l00276"></a><a class="code" href="oscl__mem_8h.html#a44">00276</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="oscl__mem_8h.html#a44">operator delete</a>(<span class="keywordtype">void</span> *aPtr) 187 00277 { 188 00278 <span class="preprocessor">#if(!OSCL_BYPASS_MEMMGT)</span> 189 00279 <span class="preprocessor"></span> <a class="code" href="group__osclmemory.html#a26">_oscl_audit_free</a>(aPtr); 190 00280 <span class="preprocessor">#else</span> 191 00281 <span class="preprocessor"></span> <a class="code" href="group__osclmemory.html#a10">_oscl_free</a>(aPtr); 192 00282 <span class="preprocessor">#endif</span> 193 00283 <span class="preprocessor"></span>}; 194 00284 195 00285 <span class="preprocessor">#if(!OSCL_BYPASS_MEMMGT)</span> 196 <a name="l00286"></a><a class="code" href="group__osclmemory.html#a30">00286</a> <span class="preprocessor"></span><span class="keyword">inline</span> <span class="keywordtype">void</span> * <a class="code" href="group__osclmemory.html#a31">operator new[]</a>(size_t aSize, <span class="keyword">const</span> <span class="keywordtype">char</span> *aFile, <span class="keywordtype">int</span> aLine) 197 00287 { 198 00288 <span class="preprocessor">#if(PVMEM_INST_LEVEL>0)</span> 199 00289 <span class="preprocessor"></span> <span class="comment">//in case NULL is passed in, record this file & line #</span> 200 00290 <span class="keywordflow">if</span> (!aFile) 201 00291 <span class="keywordflow">return</span> <a class="code" href="group__osclmemory.html#a25">_oscl_default_audit_new</a>(aSize, __FILE__, __LINE__); 202 00292 <span class="preprocessor">#endif</span> 203 00293 <span class="preprocessor"></span> <span class="keywordflow">return</span> <a class="code" href="group__osclmemory.html#a25">_oscl_default_audit_new</a>(aSize, aFile, aLine); 204 00294 }; 205 00295 <span class="preprocessor">#endif</span> 206 00296 <span class="preprocessor"></span> 207 <a name="l00297"></a><a class="code" href="group__osclmemory.html#a31">00297</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> * <a class="code" href="group__osclmemory.html#a31">operator new[]</a>(size_t aSize) 208 00298 { 209 00299 <span class="preprocessor">#if(!OSCL_BYPASS_MEMMGT)</span> 210 00300 <span class="preprocessor"></span><span class="preprocessor">#if(PVMEM_INST_LEVEL>0)</span> 211 00301 <span class="preprocessor"></span> <span class="keywordflow">return</span> <a class="code" href="group__osclmemory.html#a25">_oscl_default_audit_new</a>(aSize, __FILE__, __LINE__); 212 00302 <span class="preprocessor">#else</span> 213 00303 <span class="preprocessor"></span> <span class="keywordflow">return</span> <a class="code" href="group__osclmemory.html#a25">_oscl_default_audit_new</a>(aSize); 214 00304 <span class="preprocessor">#endif</span> 215 00305 <span class="preprocessor"></span><span class="preprocessor">#else</span> 216 00306 <span class="preprocessor"></span> <span class="keywordflow">return</span> _oscl_default_new(aSize); 217 00307 <span class="preprocessor">#endif</span> 218 00308 <span class="preprocessor"></span>}; 219 00309 220 <a name="l00310"></a><a class="code" href="group__osclmemory.html#a32">00310</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__osclmemory.html#a32">operator delete[]</a>(<span class="keywordtype">void</span> *aPtr) 221 00311 { 222 00312 <span class="preprocessor">#if(!OSCL_BYPASS_MEMMGT)</span> 223 00313 <span class="preprocessor"></span> <a class="code" href="group__osclmemory.html#a26">_oscl_audit_free</a>(aPtr); 224 00314 <span class="preprocessor">#else</span> 225 00315 <span class="preprocessor"></span> <a class="code" href="group__osclmemory.html#a10">_oscl_free</a>(aPtr); 226 00316 <span class="preprocessor">#endif</span> 227 00317 <span class="preprocessor"></span>}; 228 00318 <span class="preprocessor">#endif //OSCL_HAS_GLOBAL_NEW_DELETE</span> 229 00319 <span class="preprocessor"></span> 230 00331 <span class="preprocessor">#if(OSCL_BYPASS_MEMMGT)</span> 231 00332 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_MALLOC(count) _oscl_malloc(count)</span> 232 00333 <span class="preprocessor"></span><span class="preprocessor">#elif(PVMEM_INST_LEVEL>0)</span> 233 00334 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_MALLOC(count) _oscl_default_audit_malloc(count,__FILE__,__LINE__)</span> 234 00335 <span class="preprocessor"></span><span class="preprocessor">#else</span> 235 <a name="l00336"></a><a class="code" href="group__osclmemory.html#a39">00336</a> <span class="preprocessor"></span><span class="preprocessor">#define OSCL_MALLOC(count) _oscl_default_audit_malloc(count)</span> 236 00337 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 237 00338 <span class="preprocessor"></span> 238 00339 <span class="comment">/*</span> 239 00340 <span class="comment">** The public oscl_malloc call has been deprecated.</span> 240 00341 <span class="comment">** PV code should call OSCL_MALLOC.</span> 241 00342 <span class="comment">** This macro is defined for back-compatibility.</span> 242 00343 <span class="comment">*/</span> 243 <a name="l00344"></a><a class="code" href="group__osclmemory.html#a40">00344</a> <span class="preprocessor">#define oscl_malloc(a) OSCL_MALLOC(a)</span> 244 00345 <span class="preprocessor"></span> 245 <a name="l00349"></a><a class="code" href="group__osclmemory.html#a41">00349</a> <span class="preprocessor">#define OSCL_DEFAULT_MALLOC(x) OSCL_MALLOC(x)</span> 246 00350 <span class="preprocessor"></span> 247 00362 <span class="preprocessor">#if(OSCL_BYPASS_MEMMGT)</span> 248 00363 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_AUDIT_MALLOC(auditCB, count) _oscl_malloc(count)</span> 249 00364 <span class="preprocessor"></span><span class="preprocessor">#elif(PVMEM_INST_LEVEL>0)</span> 250 00365 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_AUDIT_MALLOC(auditCB, count) _oscl_audit_malloc(count, auditCB, __FILE__, __LINE__)</span> 251 00366 <span class="preprocessor"></span><span class="preprocessor">#else</span> 252 <a name="l00367"></a><a class="code" href="group__osclmemory.html#a42">00367</a> <span class="preprocessor"></span><span class="preprocessor">#define OSCL_AUDIT_MALLOC(auditCB, count) _oscl_audit_malloc(count, auditCB)</span> 253 00368 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 254 00369 <span class="preprocessor"></span> 255 00382 <span class="preprocessor">#if(OSCL_BYPASS_MEMMGT)</span> 256 00383 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_CALLOC(num,size) _oscl_calloc(num,size)</span> 257 00384 <span class="preprocessor"></span><span class="preprocessor">#elif(PVMEM_INST_LEVEL>0)</span> 258 00385 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_CALLOC(num,size) _oscl_default_audit_calloc(num,size,__FILE__,__LINE__)</span> 259 00386 <span class="preprocessor"></span><span class="preprocessor">#else</span> 260 <a name="l00387"></a><a class="code" href="group__osclmemory.html#a43">00387</a> <span class="preprocessor"></span><span class="preprocessor">#define OSCL_CALLOC(num,size) _oscl_default_audit_calloc(num,size)</span> 261 00388 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 262 00389 <span class="preprocessor"></span> 263 00390 <span class="comment">/*</span> 264 00391 <span class="comment">** The public oscl_calloc call has been deprecated.</span> 265 00392 <span class="comment">** PV code should call OSCL_CALLOC.</span> 266 00393 <span class="comment">** This macro is defined for back-compatibility.</span> 267 00394 <span class="comment">*/</span> 268 <a name="l00395"></a><a class="code" href="group__osclmemory.html#a44">00395</a> <span class="preprocessor">#define oscl_calloc(a,b) OSCL_CALLOC(a,b)</span> 269 00396 <span class="preprocessor"></span> 270 00410 <span class="preprocessor">#if(OSCL_BYPASS_MEMMGT)</span> 271 00411 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_AUDIT_CALLOC(auditCB, num,size) _oscl_calloc(num,size)</span> 272 00412 <span class="preprocessor"></span><span class="preprocessor">#elif(PVMEM_INST_LEVEL>0)</span> 273 00413 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_AUDIT_CALLOC(auditCB, num,size) _oscl_audit_calloc(num,size, auditCB, __FILE__, __LINE__)</span> 274 00414 <span class="preprocessor"></span><span class="preprocessor">#else</span> 275 <a name="l00415"></a><a class="code" href="group__osclmemory.html#a45">00415</a> <span class="preprocessor"></span><span class="preprocessor">#define OSCL_AUDIT_CALLOC(auditCB, num,size) _oscl_audit_calloc(num,size, auditCB)</span> 276 00416 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 277 00417 <span class="preprocessor"></span> 278 00430 <span class="preprocessor">#if(OSCL_BYPASS_MEMMGT)</span> 279 00431 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_REALLOC(ptr,new_size) _oscl_realloc(ptr,new_size)</span> 280 00432 <span class="preprocessor"></span><span class="preprocessor">#elif(PVMEM_INST_LEVEL>0)</span> 281 00433 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_REALLOC(ptr,new_size) _oscl_default_audit_realloc(ptr,new_size,__FILE__,__LINE__)</span> 282 00434 <span class="preprocessor"></span><span class="preprocessor">#else</span> 283 <a name="l00435"></a><a class="code" href="group__osclmemory.html#a46">00435</a> <span class="preprocessor"></span><span class="preprocessor">#define OSCL_REALLOC(ptr,new_size) _oscl_default_audit_realloc(ptr,new_size)</span> 284 00436 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 285 00437 <span class="preprocessor"></span> 286 00438 <span class="comment">/*</span> 287 00439 <span class="comment">** The public oscl_realloc call has been deprecated.</span> 288 00440 <span class="comment">** PV code should call OSCL_REALLOC. This macro is</span> 289 00441 <span class="comment">** defined for back-compatibility.</span> 290 00442 <span class="comment">*/</span> 291 <a name="l00443"></a><a class="code" href="group__osclmemory.html#a47">00443</a> <span class="preprocessor">#define oscl_realloc(a,b) OSCL_REALLOC(a,b)</span> 292 00444 <span class="preprocessor"></span> 293 00458 <span class="preprocessor">#if(OSCL_BYPASS_MEMMGT)</span> 294 00459 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_AUDIT_REALLOC(auditCB, ptr,new_size) _oscl_realloc(ptr,new_size)</span> 295 00460 <span class="preprocessor"></span><span class="preprocessor">#elif(PVMEM_INST_LEVEL>0)</span> 296 00461 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_AUDIT_REALLOC(auditCB, ptr,new_size) _oscl_audit_realloc(ptr,new_size, auditCB, __FILE__, __LINE__)</span> 297 00462 <span class="preprocessor"></span><span class="preprocessor">#else</span> 298 <a name="l00463"></a><a class="code" href="group__osclmemory.html#a48">00463</a> <span class="preprocessor"></span><span class="preprocessor">#define OSCL_AUDIT_REALLOC(auditCB, ptr,new_size) _oscl_audit_realloc(ptr,new_size, auditCB)</span> 299 00464 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 300 00465 <span class="preprocessor"></span> 301 00471 <span class="preprocessor">#if(OSCL_BYPASS_MEMMGT)</span> 302 00472 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_FREE(ptr) _oscl_free(ptr)</span> 303 00473 <span class="preprocessor"></span><span class="preprocessor">#else</span> 304 <a name="l00474"></a><a class="code" href="group__osclmemory.html#a49">00474</a> <span class="preprocessor"></span><span class="preprocessor">#define OSCL_FREE(ptr) _oscl_audit_free(ptr)</span> 305 00475 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 306 00476 <span class="preprocessor"></span> 307 00477 <span class="comment">/*</span> 308 00478 <span class="comment">** The public oscl_free call has been deprecated.</span> 309 00479 <span class="comment">** PV code should call OSCL_FREE.</span> 310 00480 <span class="comment">** This macro is defined for back-compatibility.</span> 311 00481 <span class="comment">*/</span> 312 <a name="l00482"></a><a class="code" href="group__osclmemory.html#a50">00482</a> <span class="preprocessor">#define oscl_free(x) OSCL_FREE(x)</span> 313 00483 <span class="preprocessor"></span> 314 <a name="l00487"></a><a class="code" href="group__osclmemory.html#a51">00487</a> <span class="preprocessor">#define OSCL_DEFAULT_FREE(x) OSCL_FREE(x)</span> 315 00488 <span class="preprocessor"></span> 316 00506 <span class="preprocessor">#if(OSCL_BYPASS_MEMMGT)</span> 317 00507 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_NEW( T, params) new T params</span> 318 00508 <span class="preprocessor"></span><span class="preprocessor">#elif!(OSCL_HAS_GLOBAL_NEW_DELETE)</span> 319 00509 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_NEW( T, params) new T params</span> 320 00510 <span class="preprocessor"></span><span class="preprocessor">#elif(PVMEM_INST_LEVEL>0)</span> 321 00511 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_NEW( T, params) new(__FILE__,__LINE__) T params</span> 322 00512 <span class="preprocessor"></span><span class="preprocessor">#else</span> 323 <a name="l00513"></a><a class="code" href="group__osclmemory.html#a52">00513</a> <span class="preprocessor"></span><span class="preprocessor">#define OSCL_NEW( T, params) new T params</span> 324 00514 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 325 00515 <span class="preprocessor"></span> 326 00516 <span class="comment">/********************************************************</span> 327 00517 <span class="comment"> * Macro for placement new</span> 328 00518 <span class="comment"> *</span> 329 00519 <span class="comment"> * @param ptr pointer to an object</span> 330 00520 <span class="comment"> *</span> 331 00521 <span class="comment"> * @param constructor constructor of the class for the object</span> 332 00522 <span class="comment"> *</span> 333 00523 <span class="comment">********************************************************/</span> 334 <a name="l00524"></a><a class="code" href="group__osclmemory.html#a53">00524</a> <span class="preprocessor">#define OSCL_PLACEMENT_NEW(ptr, constructor) new(ptr) constructor</span> 335 00525 <span class="preprocessor"></span> 336 00545 <span class="preprocessor">#if(OSCL_BYPASS_MEMMGT)</span> 337 00546 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_TRAP_NEW(T_ptr,T,params) _OSCL_TRAP_NEW(_oscl_default_new(sizeof(T)),_oscl_free,T_ptr,T,params)</span> 338 00547 <span class="preprocessor"></span><span class="preprocessor">#elif!(OSCL_HAS_GLOBAL_NEW_DELETE)</span> 339 00548 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_TRAP_NEW(T_ptr,T,params) _OSCL_TRAP_NEW(_oscl_default_audit_new(sizeof(T)),_oscl_audit_free,T_ptr,T,params)</span> 340 00549 <span class="preprocessor"></span><span class="preprocessor">#elif(PVMEM_INST_LEVEL>0)</span> 341 00550 <span class="preprocessor"></span><span class="preprocessor">#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)</span> 342 00551 <span class="preprocessor"></span><span class="preprocessor">#else</span> 343 <a name="l00552"></a><a class="code" href="group__osclmemory.html#a54">00552</a> <span class="preprocessor"></span><span class="preprocessor">#define OSCL_TRAP_NEW(T_ptr,T,params) _OSCL_TRAP_NEW(_oscl_default_audit_new(sizeof(T)),_oscl_audit_free,T_ptr,T,params)</span> 344 00553 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 345 00554 <span class="preprocessor"></span> 346 00555 347 00569 <span class="preprocessor">#if(OSCL_BYPASS_MEMMGT)</span> 348 00570 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_AUDIT_NEW(auditCB, T, params) new(_oscl_default_new(sizeof(T))) T params</span> 349 00571 <span class="preprocessor"></span><span class="preprocessor">#elif!(OSCL_HAS_GLOBAL_NEW_DELETE)</span> 350 00572 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_AUDIT_NEW(auditCB, T, params) new(_oscl_audit_new(sizeof(T),auditCB)) T params</span> 351 00573 <span class="preprocessor"></span><span class="preprocessor">#elif(PVMEM_INST_LEVEL>0)</span> 352 00574 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_AUDIT_NEW(auditCB, T, params) new(_oscl_audit_new(sizeof(T),auditCB,__FILE__,__LINE__)) T params</span> 353 00575 <span class="preprocessor"></span><span class="preprocessor">#else</span> 354 <a name="l00576"></a><a class="code" href="group__osclmemory.html#a55">00576</a> <span class="preprocessor"></span><span class="preprocessor">#define OSCL_AUDIT_NEW(auditCB, T, params) new(_oscl_audit_new(sizeof(T),auditCB)) T params</span> 355 00577 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 356 00578 <span class="preprocessor"></span> 357 00598 <span class="preprocessor">#if(OSCL_BYPASS_MEMMGT)</span> 358 00599 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_TRAP_AUDIT_NEW(T_ptr,auditCB,T,params) _OSCL_TRAP_NEW(_oscl_default_new(sizeof(T)),_oscl_free,T_ptr,T,params)</span> 359 00600 <span class="preprocessor"></span><span class="preprocessor">#elif!(OSCL_HAS_GLOBAL_NEW_DELETE)</span> 360 00601 <span class="preprocessor"></span><span class="preprocessor">#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)</span> 361 00602 <span class="preprocessor"></span><span class="preprocessor">#elif(PVMEM_INST_LEVEL>0)</span> 362 00603 <span class="preprocessor"></span><span class="preprocessor">#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)</span> 363 00604 <span class="preprocessor"></span><span class="preprocessor">#else</span> 364 <a name="l00605"></a><a class="code" href="group__osclmemory.html#a56">00605</a> <span class="preprocessor"></span><span class="preprocessor">#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)</span> 365 00606 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 366 00607 <span class="preprocessor"></span> 367 <a name="l00615"></a><a class="code" href="group__osclmemory.html#a57">00615</a> <span class="preprocessor">#define OSCL_DELETE(ptr) {\</span> 368 00616 <span class="preprocessor"> if(ptr){delete(ptr);}\</span> 369 00617 <span class="preprocessor">}</span> 370 00618 <span class="preprocessor"></span> 371 00619 372 00643 <span class="preprocessor">#if(OSCL_BYPASS_MEMMGT)</span> 373 00644 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_AUDIT_ARRAY_NEW(auditCB, T, count) new(_oscl_default_new(sizeof(T)*(count))) T</span> 374 00645 <span class="preprocessor"></span><span class="preprocessor">#elif!(OSCL_HAS_GLOBAL_NEW_DELETE)</span> 375 00646 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_AUDIT_ARRAY_NEW(auditCB, T, count) new(_oscl_audit_new(sizeof(T)*(count),auditCB)) T</span> 376 00647 <span class="preprocessor"></span><span class="preprocessor">#elif(PVMEM_INST_LEVEL>0)</span> 377 00648 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_AUDIT_ARRAY_NEW(auditCB, T, count) new(_oscl_audit_new(sizeof(T)*(count),auditCB,__FILE__,__LINE__)) T</span> 378 00649 <span class="preprocessor"></span><span class="preprocessor">#else</span> 379 <a name="l00650"></a><a class="code" href="group__osclmemory.html#a58">00650</a> <span class="preprocessor"></span><span class="preprocessor">#define OSCL_AUDIT_ARRAY_NEW(auditCB, T, count) new(_oscl_audit_new(sizeof(T)*(count),auditCB)) T</span> 380 00651 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 381 00652 <span class="preprocessor"></span> 382 00666 <span class="preprocessor">#if(OSCL_BYPASS_MEMMGT)</span> 383 00667 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_ARRAY_NEW(T, count) new T[count]</span> 384 00668 <span class="preprocessor"></span><span class="preprocessor">#elif!(OSCL_HAS_GLOBAL_NEW_DELETE)</span> 385 00669 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_ARRAY_NEW(T, count) new T[count]</span> 386 00670 <span class="preprocessor"></span><span class="preprocessor">#elif(PVMEM_INST_LEVEL>0)</span> 387 00671 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_ARRAY_NEW(T, count) new(__FILE__,__LINE__) T[count]</span> 388 00672 <span class="preprocessor"></span><span class="preprocessor">#else</span> 389 <a name="l00673"></a><a class="code" href="group__osclmemory.html#a59">00673</a> <span class="preprocessor"></span><span class="preprocessor">#define OSCL_ARRAY_NEW(T, count) new T[count]</span> 390 00674 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 391 00675 <span class="preprocessor"></span> 392 <a name="l00683"></a><a class="code" href="group__osclmemory.html#a60">00683</a> <span class="preprocessor">#define OSCL_ARRAY_DELETE(ptr) delete [] ptr</span> 393 00684 <span class="preprocessor"></span> 394 00685 395 00690 <span class="preprocessor">#ifndef OSCL_DEFALLOC_H_INCLUDED</span> 396 00691 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__defalloc_8h.html">oscl_defalloc.h</a>"</span> 397 00692 <span class="preprocessor">#endif</span> 398 00693 <span class="preprocessor"></span> 399 00694 <span class="preprocessor">#ifndef OSCL_REFCOUNTER_H_INCLUDED</span> 400 00695 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__refcounter_8h.html">oscl_refcounter.h</a>"</span> 401 00696 <span class="preprocessor">#endif</span> 402 00697 <span class="preprocessor"></span> 403 00698 <span class="preprocessor">#ifndef OSCL_MEM_BASIC_FUNCTIONS_H_INCLUDED</span> 404 00699 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__mem__basic__functions_8h.html">oscl_mem_basic_functions.h</a>"</span> 405 00700 <span class="preprocessor">#endif</span> 406 00701 <span class="preprocessor"></span> 407 00702 <span class="preprocessor">#ifndef OSCL_ERROR_H_INCLUDED</span> 408 00703 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__error_8h.html">oscl_error.h</a>"</span> 409 00704 <span class="preprocessor">#endif</span> 410 00705 <span class="preprocessor"></span> 411 00706 <span class="preprocessor">#ifndef OSCL_EXCEPTION_H_INCLUDED</span> 412 00707 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__exception_8h.html">oscl_exception.h</a>"</span> 413 00708 <span class="preprocessor">#endif</span> 414 00709 <span class="preprocessor"></span> 415 <a name="l00710"></a><a class="code" href="oscl__mem_8h.html#a28">00710</a> <span class="preprocessor">#define OSCL_DISABLE_WARNING_TRUNCATE_DEBUG_MESSAGE</span> 416 00711 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="osclconfig__compiler__warnings_8h.html">osclconfig_compiler_warnings.h</a>"</span> 417 00712 418 00713 <span class="comment">// This macro is defined is osclconfig_compiler_warnings.h</span> 419 00714 <span class="comment">// This GCC #pragma turns off compiler warning for the rest of this header file</span> 420 00715 <span class="comment">// This needs to be done because with the GCC 4.1 toolchain, many compiler warnings</span> 421 00716 <span class="comment">// are generated because Oscl_MemAllocator and Oscl_MemBasicAllocator have virtual functions, but</span> 422 00717 <span class="comment">// no virtual destructor.</span> 423 00718 <span class="comment">// An attempt has been made to add the virtual destructors, however, it resulted</span> 424 00719 <span class="comment">// in run time crashes indicative of double freeing of memory.</span> 425 00720 <span class="comment">// This is a temporary fix, until the crashes are resolved.</span> 426 00721 <span class="comment">//</span> 427 00722 <span class="preprocessor">#ifdef OSCL_DISABLE_GCC_WARNING_SYSTEM_HEADER</span> 428 00723 <span class="preprocessor"></span><span class="preprocessor">#pragma GCC system_header</span> 429 00724 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 430 00725 <span class="preprocessor"></span> 431 <a name="l00731"></a><a class="code" href="classOsclMemAllocator.html">00731</a> <span class="keyword">class </span><a class="code" href="classOsclMemAllocator.html">OsclMemAllocator</a> : <span class="keyword">public</span> <a class="code" href="classOscl__DefAlloc.html">Oscl_DefAlloc</a> 432 00732 { 433 00733 <span class="keyword">public</span>: 434 <a name="l00740"></a><a class="code" href="classOsclMemAllocator.html#a0">00740</a> <a class="code" href="group__osclbase.html#a25">OsclAny</a>* <a class="code" href="classOsclMemAllocator.html#a0">allocate</a>(<span class="keyword">const</span> uint32 n) 435 00741 { 436 00742 <span class="preprocessor">#if(OSCL_BYPASS_MEMMGT)</span> 437 00743 <span class="preprocessor"></span> <a class="code" href="group__osclbase.html#a25">OsclAny</a>* p = <a class="code" href="group__osclmemory.html#a7">_oscl_malloc</a>(n); 438 00744 <span class="keywordflow">if</span> (!p) 439 00745 <a class="code" href="classOsclError.html#d8">OsclError::LeaveIfNull</a>(p); 440 00746 <span class="preprocessor">#if OSCL_MEM_FILL_WITH_PATTERN</span> 441 00747 <span class="preprocessor"></span> <a class="code" href="group__osclmemory.html#a14">oscl_memset</a>(p, 0x55, n); 442 00748 <span class="preprocessor">#endif</span> 443 00749 <span class="preprocessor"></span> <span class="keywordflow">return</span> (p); 444 00750 <span class="preprocessor">#elif (PVMEM_INST_LEVEL>0)</span> 445 00751 <span class="preprocessor"></span> <span class="comment">//this is really a usage error-- caller should provide file & line.</span> 446 00752 <span class="comment">//set a debug breakpoint here...</span> 447 00753 <span class="keywordflow">return</span> <a class="code" href="classOsclMemAllocator.html#a1">allocate_fl</a>(n, __FILE__, __LINE__); 448 00754 <span class="preprocessor">#else</span> 449 00755 <span class="preprocessor"></span> <span class="keywordflow">return</span> <a class="code" href="classOsclMemAllocator.html#a1">allocate_fl</a>(n, <a class="code" href="group__osclbase.html#a81">NULL</a>, 0); 450 00756 <span class="preprocessor">#endif</span> 451 00757 <span class="preprocessor"></span> } 452 00758 453 00759 <span class="preprocessor">#if(!OSCL_BYPASS_MEMMGT)</span> 454 <a name="l00760"></a><a class="code" href="classOsclMemAllocator.html#a1">00760</a> <span class="preprocessor"></span> <a class="code" href="group__osclbase.html#a25">OsclAny</a>* <a class="code" href="classOsclMemAllocator.html#a1">allocate_fl</a>(<span class="keyword">const</span> uint32 n, <span class="keyword">const</span> <span class="keywordtype">char</span> * file_name, <span class="keyword">const</span> <span class="keywordtype">int</span> line_num) 455 00761 { 456 00762 <a class="code" href="group__osclbase.html#a25">OsclAny</a>* p = <a class="code" href="group__osclmemory.html#a22">_oscl_default_audit_malloc</a>(n, file_name, line_num); 457 00763 <span class="keywordflow">if</span> (!p) 458 00764 <a class="code" href="classOsclError.html#d8">OsclError::LeaveIfNull</a>(p); 459 00765 <span class="preprocessor">#if OSCL_MEM_FILL_WITH_PATTERN</span> 460 00766 <span class="preprocessor"></span> <a class="code" href="group__osclmemory.html#a14">oscl_memset</a>(p, 0x55, n); 461 00767 <span class="preprocessor">#endif</span> 462 00768 <span class="preprocessor"></span> <span class="keywordflow">return</span> (p); 463 00769 } 464 00770 <span class="preprocessor">#endif</span> 465 00771 <span class="preprocessor"></span> 466 <a name="l00772"></a><a class="code" href="classOsclMemAllocator.html#a2">00772</a> <span class="keywordtype">void</span> <a class="code" href="classOsclMemAllocator.html#a2">deallocate</a>(<a class="code" href="group__osclbase.html#a25">OsclAny</a>* p) 467 00773 { 468 00774 <span class="keywordflow">if</span> (p) 469 00775 <a class="code" href="group__osclmemory.html#a49">OSCL_FREE</a>(p); 470 00776 } 471 00777 }; 472 00778 473 00779 474 <a name="l00787"></a><a class="code" href="classOsclMemBasicAllocator.html">00787</a> <span class="keyword">class </span><a class="code" href="classOsclMemBasicAllocator.html">OsclMemBasicAllocator</a> : <span class="keyword">public</span> <a class="code" href="classOscl__DefAlloc.html">Oscl_DefAlloc</a> 475 00788 { 476 00789 <span class="keyword">public</span>: 477 <a name="l00796"></a><a class="code" href="classOsclMemBasicAllocator.html#a0">00796</a> <a class="code" href="group__osclbase.html#a25">OsclAny</a>* <a class="code" href="classOsclMemBasicAllocator.html#a0">allocate</a>(<span class="keyword">const</span> uint32 n) 478 00797 { 479 00798 <a class="code" href="group__osclbase.html#a25">OsclAny</a>* p = <a class="code" href="group__osclmemory.html#a7">_oscl_malloc</a>(n); 480 00799 <a class="code" href="classOsclError.html#d8">OsclError::LeaveIfNull</a>(p); 481 00800 <span class="preprocessor">#if OSCL_MEM_FILL_WITH_PATTERN</span> 482 00801 <span class="preprocessor"></span> <a class="code" href="group__osclmemory.html#a14">oscl_memset</a>(p, 0x55, n); 483 00802 <span class="preprocessor">#endif</span> 484 00803 <span class="preprocessor"></span> <span class="keywordflow">return</span> (p); 485 00804 } 486 00805 487 <a name="l00806"></a><a class="code" href="classOsclMemBasicAllocator.html#a1">00806</a> <span class="keywordtype">void</span> <a class="code" href="classOsclMemBasicAllocator.html#a1">deallocate</a>(<a class="code" href="group__osclbase.html#a25">OsclAny</a>* p) 488 00807 { 489 00808 <span class="keywordflow">if</span> (p) 490 00809 <a class="code" href="group__osclmemory.html#a10">_oscl_free</a>(p); 491 00810 } 492 00811 }; 493 00812 494 <a name="l00817"></a><a class="code" href="classOsclMemAllocDestructDealloc.html">00817</a> <span class="keyword">template</span> <<span class="keyword">class</span> T> <span class="keyword">class </span><a class="code" href="classOsclMemAllocDestructDealloc.html">OsclMemAllocDestructDealloc</a> : <span class="keyword">public</span> <a class="code" href="classOsclAllocDestructDealloc.html">OsclAllocDestructDealloc</a> 495 00818 { 496 00819 <span class="keyword">public</span>: 497 00820 <span class="preprocessor">#if !(OSCL_BYPASS_MEMMGT)</span> 498 <a name="l00821"></a><a class="code" href="classOsclMemAllocDestructDealloc.html#a0">00821</a> <span class="preprocessor"></span> <a class="code" href="group__osclbase.html#a25">OsclAny</a>* <a class="code" href="classOsclMemAllocDestructDealloc.html#a0">allocate_fl</a>(<span class="keyword">const</span> uint32 size, <span class="keyword">const</span> <span class="keywordtype">char</span> * file_name, <span class="keyword">const</span> <span class="keywordtype">int</span> line_num) 499 00822 { 500 00823 <span class="keywordflow">return</span> alloc.<a class="code" href="classOsclMemAllocator.html#a1">allocate_fl</a>(size, file_name, line_num); 501 00824 } 502 00825 <span class="preprocessor">#endif</span> 503 <a name="l00826"></a><a class="code" href="classOsclMemAllocDestructDealloc.html#a1">00826</a> <span class="preprocessor"></span> <a class="code" href="group__osclbase.html#a25">OsclAny</a>* <a class="code" href="classOsclMemAllocDestructDealloc.html#a1">allocate</a>(<span class="keyword">const</span> uint32 size) 504 00827 { 505 00828 <span class="preprocessor">#if(OSCL_BYPASS_MEMMGT)</span> 506 00829 <span class="preprocessor"></span> <span class="keywordflow">return</span> alloc.<a class="code" href="classOsclMemAllocator.html#a0">allocate</a>(size); 507 00830 <span class="preprocessor">#elif(PVMEM_INST_LEVEL>0)</span> 508 00831 <span class="preprocessor"></span> <span class="comment">//this is really a usage error-- caller should provide file & line.</span> 509 00832 <span class="comment">//set a debug breakpoint here...</span> 510 00833 <span class="keywordflow">return</span> <a class="code" href="classOsclMemAllocDestructDealloc.html#a0">allocate_fl</a>(size, __FILE__, __LINE__); 511 00834 <span class="preprocessor">#else</span> 512 00835 <span class="preprocessor"></span> <span class="keywordflow">return</span> <a class="code" href="classOsclMemAllocDestructDealloc.html#a0">allocate_fl</a>(size, <a class="code" href="group__osclbase.html#a81">NULL</a>, 0); 513 00836 <span class="preprocessor">#endif</span> 514 00837 <span class="preprocessor"></span> } 515 <a name="l00838"></a><a class="code" href="classOsclMemAllocDestructDealloc.html#a2">00838</a> <span class="keywordtype">void</span> <a class="code" href="classOsclMemAllocDestructDealloc.html#a2">deallocate</a>(<a class="code" href="group__osclbase.html#a25">OsclAny</a>* p) 516 00839 { 517 00840 alloc.<a class="code" href="classOsclMemAllocator.html#a2">deallocate</a>(p); 518 00841 } 519 <a name="l00842"></a><a class="code" href="classOsclMemAllocDestructDealloc.html#a3">00842</a> <span class="keywordtype">void</span> <a class="code" href="classOsclMemAllocDestructDealloc.html#a3">destruct_and_dealloc</a>(<a class="code" href="group__osclbase.html#a25">OsclAny</a>* p) 520 00843 { 521 00844 T* ptr = reinterpret_cast<T*>(p); 522 00845 ptr->~T(); 523 00846 <a class="code" href="classOsclMemAllocDestructDealloc.html#a2">deallocate</a>(p); 524 00847 <a class="code" href="group__osclbase.html#a89">OSCL_UNUSED_ARG</a>(ptr); <span class="comment">// removes warning on some compilers</span> 525 00848 } 526 00849 <span class="keyword">private</span>: 527 00850 <a class="code" href="classOsclMemAllocator.html">OsclMemAllocator</a> alloc; 528 00851 }; 529 00852 530 <a name="l00857"></a><a class="code" href="classOsclMemBasicAllocDestructDealloc.html">00857</a> <span class="keyword">template</span> <<span class="keyword">class</span> T> <span class="keyword">class </span><a class="code" href="classOsclMemBasicAllocDestructDealloc.html">OsclMemBasicAllocDestructDealloc</a> : <span class="keyword">public</span> <a class="code" href="classOsclAllocDestructDealloc.html">OsclAllocDestructDealloc</a> 531 00858 { 532 00859 <span class="keyword">public</span>: 533 <a name="l00860"></a><a class="code" href="classOsclMemBasicAllocDestructDealloc.html#a0">00860</a> <a class="code" href="group__osclbase.html#a25">OsclAny</a>* <a class="code" href="classOsclMemBasicAllocDestructDealloc.html#a0">allocate</a>(<span class="keyword">const</span> uint32 size) 534 00861 { 535 00862 <span class="preprocessor">#if(OSCL_BYPASS_MEMMGT)</span> 536 00863 <span class="preprocessor"></span> <span class="keywordflow">return</span> alloc.<a class="code" href="classOsclMemBasicAllocator.html#a0">allocate</a>(size); 537 00864 <span class="preprocessor">#else</span> 538 00865 <span class="preprocessor"></span> <span class="keywordflow">return</span> alloc.<a class="code" href="classOscl__DefAlloc.html#a1">allocate_fl</a>(size, <a class="code" href="group__osclbase.html#a81">NULL</a>, 0); 539 00866 <span class="preprocessor">#endif</span> 540 00867 <span class="preprocessor"></span> } 541 <a name="l00868"></a><a class="code" href="classOsclMemBasicAllocDestructDealloc.html#a1">00868</a> <span class="keywordtype">void</span> <a class="code" href="classOsclMemBasicAllocDestructDealloc.html#a1">deallocate</a>(<a class="code" href="group__osclbase.html#a25">OsclAny</a>* p) 542 00869 { 543 00870 alloc.<a class="code" href="classOsclMemBasicAllocator.html#a1">deallocate</a>(p); 544 00871 } 545 <a name="l00872"></a><a class="code" href="classOsclMemBasicAllocDestructDealloc.html#a2">00872</a> <span class="keywordtype">void</span> <a class="code" href="classOsclMemBasicAllocDestructDealloc.html#a2">destruct_and_dealloc</a>(<a class="code" href="group__osclbase.html#a25">OsclAny</a>* p) 546 00873 { 547 00874 T* ptr = reinterpret_cast<T*>(p); 548 00875 ptr->~T(); 549 00876 <a class="code" href="classOsclMemBasicAllocDestructDealloc.html#a1">deallocate</a>(p); 550 00877 <a class="code" href="group__osclbase.html#a89">OSCL_UNUSED_ARG</a>(ptr); <span class="comment">// removes warning on some compilers</span> 551 00878 } 552 00879 <span class="keyword">private</span>: 553 00880 <a class="code" href="classOsclMemBasicAllocator.html">OsclMemBasicAllocator</a> alloc; 554 00881 }; 555 00882 556 00887 <span class="keyword">class </span><a class="code" href="classOsclMemAudit.html">OsclMemAudit</a>; 557 <a name="l00888"></a><a class="code" href="classOsclMemGlobalAuditObject.html">00888</a> <span class="keyword">class </span><a class="code" href="classOsclMemGlobalAuditObject.html">OsclMemGlobalAuditObject</a> 558 00889 { 559 00890 <span class="keyword">public</span>: 560 <a name="l00891"></a><a class="code" href="classOsclMemGlobalAuditObject.html#s0">00891</a> <span class="keyword">typedef</span> <a class="code" href="classOsclMemAudit.html">OsclMemAudit</a> <a class="code" href="classOsclMemAudit.html">audit_type</a>; 561 00896 OSCL_IMPORT_REF <span class="keyword">static</span> audit_type* <a class="code" href="classOsclMemGlobalAuditObject.html#d0">getGlobalMemAuditObject</a>(); 562 00897 563 00898 <span class="keyword">private</span>: 564 00902 <span class="keyword">static</span> <span class="keywordtype">void</span> createGlobalMemAuditObject(); 565 00903 566 00907 <span class="keyword">static</span> <span class="keywordtype">void</span> deleteGlobalMemAuditObject(); 567 00908 568 <a name="l00909"></a><a class="code" href="classOsclMemGlobalAuditObject.html#l0">00909</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classOsclMem.html">OsclMem</a>; 569 00910 }; 570 00911 571 <a name="l00923"></a><a class="code" href="classHeapBase.html">00923</a> <span class="keyword">class </span><a class="code" href="classHeapBase.html">HeapBase</a> : <span class="keyword">public</span> <a class="code" href="class__OsclHeapBase.html">_OsclHeapBase</a> 572 00924 { 573 00925 <span class="keyword">public</span>: 574 00926 <span class="preprocessor">#if (OSCL_HAS_HEAP_BASE_SUPPORT)</span> 575 00927 <span class="preprocessor"></span> 576 00928 <span class="preprocessor">#if(!OSCL_BYPASS_MEMMGT)</span> 577 00929 <span class="preprocessor"></span> <span class="keyword">static</span> <span class="keywordtype">void</span>* <a class="code" href="oscl__mem_8h.html#a43">operator new</a>(size_t aSize, <span class="keyword">const</span> <span class="keywordtype">char</span> *aFile = <a class="code" href="group__osclbase.html#a81">NULL</a>, <span class="keyword">const</span> <span class="keywordtype">int</span> aLine = 0) 578 00930 { 579 00931 <span class="preprocessor">#if(PVMEM_INST_LEVEL>0)</span> 580 00932 <span class="preprocessor"></span> <span class="comment">//in case NULL is passed in, record this file & line #</span> 581 00933 <span class="keywordflow">if</span> (!aFile) 582 00934 <span class="keywordflow">return</span> <a class="code" href="group__osclmemory.html#a25">_oscl_default_audit_new</a>(aSize, __FILE__, __LINE__); 583 00935 <span class="preprocessor">#endif</span> 584 00936 <span class="preprocessor"></span> <span class="keywordflow">return</span> <a class="code" href="group__osclmemory.html#a25">_oscl_default_audit_new</a>(aSize, aFile, aLine); 585 00937 } 586 00938 <span class="preprocessor">#else</span> 587 00939 <span class="preprocessor"></span> <span class="keyword">static</span> <span class="keywordtype">void</span>* <a class="code" href="oscl__mem_8h.html#a43">operator new</a>(size_t aSize) 588 00940 { 589 00941 <span class="keywordflow">return</span> _oscl_default_new(aSize); 590 00942 } 591 00943 <span class="preprocessor">#endif</span> 592 00944 <span class="preprocessor"></span> 593 00945 <span class="keyword">static</span> <span class="keywordtype">void</span>* <a class="code" href="group__osclmemory.html#a31">operator new[]</a>(size_t aSize) 594 00946 { 595 00947 <span class="preprocessor">#if(!OSCL_BYPASS_MEMMGT)</span> 596 00948 <span class="preprocessor"></span> <span class="keywordflow">return</span> <a class="code" href="group__osclmemory.html#a25">_oscl_default_audit_new</a>(aSize); 597 00949 <span class="preprocessor">#else</span> 598 00950 <span class="preprocessor"></span> <span class="keywordflow">return</span> _oscl_default_new(aSize); 599 00951 <span class="preprocessor">#endif</span> 600 00952 <span class="preprocessor"></span> } 601 00953 602 00954 <span class="keyword">static</span> <span class="keywordtype">void</span>* <a class="code" href="group__osclmemory.html#a31">operator new[]</a>(size_t aSize, <span class="keyword">const</span> <span class="keywordtype">char</span> *aFile = <a class="code" href="group__osclbase.html#a81">NULL</a>, <span class="keyword">const</span> <span class="keywordtype">int</span> aLine = 0) 603 00955 { 604 00956 <span class="preprocessor">#if(!OSCL_BYPASS_MEMMGT)</span> 605 00957 <span class="preprocessor"></span><span class="preprocessor">#if(PVMEM_INST_LEVEL>0)</span> 606 00958 <span class="preprocessor"></span> <span class="comment">//in case NULL is passed in, record this file & line #</span> 607 00959 <span class="keywordflow">if</span> (!aFile) 608 00960 <span class="keywordflow">return</span> <a class="code" href="group__osclmemory.html#a25">_oscl_default_audit_new</a>(aSize, __FILE__, __LINE__); 609 00961 <span class="preprocessor">#endif</span> 610 00962 <span class="preprocessor"></span> <span class="keywordflow">return</span> <a class="code" href="group__osclmemory.html#a25">_oscl_default_audit_new</a>(aSize, aFile, aLine); 611 00963 <span class="preprocessor">#else</span> 612 00964 <span class="preprocessor"></span> <a class="code" href="group__osclbase.html#a89">OSCL_UNUSED_ARG</a>(aFile); 613 00965 <a class="code" href="group__osclbase.html#a89">OSCL_UNUSED_ARG</a>(aLine); 614 00966 <span class="keywordflow">return</span> _oscl_default_new(aSize); 615 00967 <span class="preprocessor">#endif</span> 616 00968 <span class="preprocessor"></span> } 617 00969 618 00970 <span class="keyword">static</span> <span class="keywordtype">void</span>* <a class="code" href="oscl__mem_8h.html#a43">operator new</a>(size_t aSize, <span class="keywordtype">void</span> *aPtr) 619 00971 { 620 00972 <span class="keywordflow">return</span> aPtr; 621 00973 } 622 00974 623 00975 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="oscl__mem_8h.html#a44">operator delete</a>(<span class="keywordtype">void</span>* aPtr) 624 00976 { 625 00977 <span class="preprocessor">#if(!OSCL_BYPASS_MEMMGT)</span> 626 00978 <span class="preprocessor"></span> <a class="code" href="group__osclmemory.html#a26">_oscl_audit_free</a>(aPtr); 627 00979 <span class="preprocessor">#else</span> 628 00980 <span class="preprocessor"></span> <a class="code" href="group__osclmemory.html#a10">_oscl_free</a>(aPtr); 629 00981 <span class="preprocessor">#endif</span> 630 00982 <span class="preprocessor"></span> } 631 00983 632 00984 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="group__osclmemory.html#a32">operator delete[]</a>(<span class="keywordtype">void</span>* aPtr) 633 00985 { 634 00986 <span class="preprocessor">#if(!OSCL_BYPASS_MEMMGT)</span> 635 00987 <span class="preprocessor"></span> <a class="code" href="group__osclmemory.html#a26">_oscl_audit_free</a>(aPtr); 636 00988 <span class="preprocessor">#else</span> 637 00989 <span class="preprocessor"></span> <a class="code" href="group__osclmemory.html#a10">_oscl_free</a>(aPtr); 638 00990 <span class="preprocessor">#endif</span> 639 00991 <span class="preprocessor"></span> } 640 00992 <span class="preprocessor">#endif //OSCL_HAS_HEAP_BASE_SUPPORT</span> 641 <a name="l00993"></a><a class="code" href="classHeapBase.html#a0">00993</a> <span class="preprocessor"></span> <a class="code" href="classHeapBase.html#a0">HeapBase</a>() {}; 642 <a name="l00994"></a><a class="code" href="classHeapBase.html#a1">00994</a> <span class="keyword">virtual</span> <a class="code" href="classHeapBase.html#a1">~HeapBase</a>() {}; 643 00995 }; 644 00996 645 <a name="l01013"></a><a class="code" href="group__osclmemory.html#a61">01013</a> <span class="preprocessor">#define _OSCL_TRAP_NEW(exp,freeFunc,T_ptr,T,params)\</span> 646 01014 <span class="preprocessor">{\</span> 647 01015 <span class="preprocessor"> int32 __err;\</span> 648 01016 <span class="preprocessor"> OsclAny*__ptr=exp;\</span> 649 01017 <span class="preprocessor"> OSCL_TRY(__err,T_ptr=new(__ptr) T params;);\</span> 650 01018 <span class="preprocessor"> if(__err){\</span> 651 01019 <span class="preprocessor"> freeFunc(__ptr);\</span> 652 01020 <span class="preprocessor"> T_ptr=NULL;\</span> 653 01021 <span class="preprocessor"> OsclError::Leave(__err);\</span> 654 01022 <span class="preprocessor"> }\</span> 655 01023 <span class="preprocessor">}</span> 656 01024 <span class="preprocessor"></span> 657 01032 <span class="preprocessor">#ifdef PVERROR_IMP_CPP_EXCEPTIONS</span> 658 01033 <span class="preprocessor"></span><span class="comment">//when using C++ exceptions, base class cleanup is automatic</span> 659 01034 <span class="preprocessor">#define _OSCL_CLEANUP_BASE_CLASS(T)</span> 660 01035 <span class="preprocessor"></span><span class="preprocessor">#else</span> 661 01036 <span class="preprocessor"></span><span class="comment">//otherwise the destructor needs to be called explicitly.</span> 662 <a name="l01037"></a><a class="code" href="group__osclmemory.html#a62">01037</a> <span class="preprocessor">#define _OSCL_CLEANUP_BASE_CLASS(T) this->T::~T()</span> 663 01038 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 664 01039 <span class="preprocessor"></span> 665 01040 666 01044 <span class="preprocessor">#if (!OSCL_DISABLE_INLINES)</span> 667 01045 <span class="preprocessor"></span><span class="preprocessor">#include "oscl_mem.inl"</span> 668 01046 <span class="preprocessor">#endif</span> 669 01047 <span class="preprocessor"></span> 670 01048 <span class="preprocessor">#endif // OSCL_MEM_H_INCLUDED</span> 671 01049 <span class="preprocessor"></span> 672 01050 673 01051 674 </pre></div><hr size="1"><img src="pvlogo_small.jpg"><address style="align: right;"><small>OSCL API</small> 675 <address style="align: left;"><small>Posting Version: OPENCORE_20090310 </small> 676 </small></address> 677 </body> 678 </html> 679