1 | #ifndef NX_FOUNDATION_NXUSERALLOCATOR
|
---|
2 | #define NX_FOUNDATION_NXUSERALLOCATOR
|
---|
3 | /*----------------------------------------------------------------------------*\
|
---|
4 | |
|
---|
5 | | Public Interface to NovodeX Technology
|
---|
6 | |
|
---|
7 | | www.novodex.com
|
---|
8 | |
|
---|
9 | \*----------------------------------------------------------------------------*/
|
---|
10 | /** \addtogroup foundation
|
---|
11 | @{
|
---|
12 | */
|
---|
13 |
|
---|
14 | #include "Nx.h"
|
---|
15 |
|
---|
16 | class NxUserAllocator;
|
---|
17 |
|
---|
18 | /**
|
---|
19 | \brief Enum tp identify memory allocations within the SDK.
|
---|
20 | */
|
---|
21 | enum NxMemoryType
|
---|
22 | {
|
---|
23 | NX_MEMORY_PERSISTENT,
|
---|
24 | NX_MEMORY_TEMP,
|
---|
25 | NX_MEMORY_Articulation,
|
---|
26 | NX_MEMORY_ArticulationMaximal,
|
---|
27 | NX_MEMORY_AxisConstraint,
|
---|
28 | NX_MEMORY_Body,
|
---|
29 | NX_MEMORY_BoxShape,
|
---|
30 | NX_MEMORY_CapsuleShape,
|
---|
31 | NX_MEMORY_WheelShape,
|
---|
32 | NX_MEMORY_CollisionMap,
|
---|
33 | NX_MEMORY_CompoundShape,
|
---|
34 | NX_MEMORY_ConvexMeshBuilder,
|
---|
35 | NX_MEMORY_ConvexMeshRuntime,
|
---|
36 | NX_MEMORY_ConvexShape,
|
---|
37 | NX_MEMORY_DebugRenderable,
|
---|
38 | NX_MEMORY_Edge,
|
---|
39 | NX_MEMORY_Fluid,
|
---|
40 | NX_MEMORY_FluidEmitter,
|
---|
41 | NX_MEMORY_FluidManager,
|
---|
42 | NX_MEMORY_FrictionPatch,
|
---|
43 | NX_MEMORY_ImplicitMesh,
|
---|
44 | NX_MEMORY_ExtraTrigData,
|
---|
45 | NX_MEMORY_JointBreakEvent,
|
---|
46 | NX_MEMORY_KinematicTarget,
|
---|
47 | NX_MEMORY_LimitPlane,
|
---|
48 | NX_MEMORY_Material,
|
---|
49 | NX_MEMORY_NpActor,
|
---|
50 | NX_MEMORY_NpMaterial,
|
---|
51 | NX_MEMORY_NvJointBreakEvent,
|
---|
52 | NX_MEMORY_NxArraySDK_NameBinding,
|
---|
53 | NX_MEMORY_FoundationSDK,
|
---|
54 | NX_MEMORY_NxMutex,
|
---|
55 | NX_MEMORY_PenetrationMap,
|
---|
56 | NX_MEMORY_PersistentPairData,
|
---|
57 | NX_MEMORY_PhysicsSDK,
|
---|
58 | NX_MEMORY_PlaneShape,
|
---|
59 | NX_MEMORY_Scene,
|
---|
60 | NX_MEMORY_ShapeInstancePair2,
|
---|
61 | NX_MEMORY_SolverBody,
|
---|
62 | NX_MEMORY_SphereShape,
|
---|
63 | NX_MEMORY_SpringAndDamperEffector,
|
---|
64 | NX_MEMORY_TriangleMesh,
|
---|
65 | NX_MEMORY_TriangleMeshBuilder,
|
---|
66 | NX_MEMORY_TriangleMeshShape,
|
---|
67 | NX_MEMORY_NpPlaneShape,
|
---|
68 | NX_MEMORY_NpSphereShape,
|
---|
69 | NX_MEMORY_NpBoxShape,
|
---|
70 | NX_MEMORY_NpCapsuleShape,
|
---|
71 | NX_MEMORY_NpConvexShape,
|
---|
72 | NX_MEMORY_NpTriangleMeshShape,
|
---|
73 | NX_MEMORY_NpWheelShape,
|
---|
74 | NX_MEMORY_NpScene,
|
---|
75 | NX_MEMORY_NpTriangleMesh,
|
---|
76 | NX_MEMORY_NpConvexMesh,
|
---|
77 | NX_MEMORY_NpPhysicsSDK,
|
---|
78 | NX_MEMORY_PhysicsThread,
|
---|
79 | NX_MEMORY_NpPrismaticJoint,
|
---|
80 | NX_MEMORY_NpRevoluteJoint,
|
---|
81 | NX_MEMORY_NpCylindricalJoint,
|
---|
82 | NX_MEMORY_NpSphericalJoint,
|
---|
83 | NX_MEMORY_NpPointOnLineJoint,
|
---|
84 | NX_MEMORY_NpPointInPlaneJoint,
|
---|
85 | NX_MEMORY_NpFixedJoint,
|
---|
86 | NX_MEMORY_NpDistanceJoint,
|
---|
87 | NX_MEMORY_NpPulleyJoint,
|
---|
88 | NX_MEMORY_NpD6Joint,
|
---|
89 | NX_MEMORY_NpSpringAndDamperEffector,
|
---|
90 | NX_MEMORY_NpFluid,
|
---|
91 | NX_MEMORY_PrismaticJoint,
|
---|
92 | NX_MEMORY_RevoluteJoint,
|
---|
93 | NX_MEMORY_CylindricalJoint,
|
---|
94 | NX_MEMORY_SphericalJoint,
|
---|
95 | NX_MEMORY_PointOnLineJoint,
|
---|
96 | NX_MEMORY_PointInPlaneJoint,
|
---|
97 | NX_MEMORY_DistanceJoint,
|
---|
98 | NX_MEMORY_PulleyJoint,
|
---|
99 | NX_MEMORY_FixedJoint,
|
---|
100 | NX_MEMORY_D6Joint,
|
---|
101 | NX_MEMORY_NpFluidEmitter,
|
---|
102 | NX_MEMORY_NpImplicitMesh,
|
---|
103 | NX_MEMORY_NpCCDSkeleton,
|
---|
104 | NX_MEMORY_SourceCCDSkeleton,
|
---|
105 | NX_MEMORY_Array,
|
---|
106 | NX_MEMORY_SolverCoreGeneral,
|
---|
107 | NX_MEMORY_SolverCoreSSE,
|
---|
108 |
|
---|
109 |
|
---|
110 | NX_MEMORY_SoftwareSceneGraphUpdatePCM,
|
---|
111 | NX_MEMORY_SoftwarePoseChangeNotifyPCM,
|
---|
112 | NX_MEMORY_SoftwareBroadPhasePCM,
|
---|
113 | NX_MEMORY_SoftwarePairCachePCM,
|
---|
114 | NX_MEMORY_SoftwareNarrowPhasePCM,
|
---|
115 | NX_MEMORY_SoftwareIslandDetectionPCM,
|
---|
116 | NX_MEMORY_SoftwareBodyPrepPCM,
|
---|
117 | NX_MEMORY_SoftwareConstraintPrepPCM,
|
---|
118 | NX_MEMORY_SoftwarePoseIntegratePCM,
|
---|
119 | NX_MEMORY_SoftwareConstraintSolvePCM,
|
---|
120 | NX_MEMORY_SoftwarePackPCM,
|
---|
121 |
|
---|
122 | /* FW DDI objects */
|
---|
123 | NX_MEMORY_PPUDataStream,
|
---|
124 | NX_MEMORY_NfArticulation,
|
---|
125 | NX_MEMORY_NfArticulationMaximal,
|
---|
126 | NX_MEMORY_NfBody,
|
---|
127 | NX_MEMORY_NfConvexMapper,
|
---|
128 | NX_MEMORY_NfJoint,
|
---|
129 | NX_MEMORY_NfMaterial,
|
---|
130 | NX_MEMORY_NfPPUDebug,
|
---|
131 | NX_MEMORY_NfPage,
|
---|
132 | NX_MEMORY_NfPageHash,
|
---|
133 | NX_MEMORY_NfPageInstanceMapper,
|
---|
134 | NX_MEMORY_NfPageMapper,
|
---|
135 | NX_MEMORY_NfPhysicsSDK,
|
---|
136 | NX_MEMORY_NfProfileOutput,
|
---|
137 | NX_MEMORY_NfProjectionTree,
|
---|
138 | NX_MEMORY_NfRBFwPipeline,
|
---|
139 | NX_MEMORY_NfRBSwPipeline,
|
---|
140 | NX_MEMORY_NfRBDebugPipeline,
|
---|
141 | NX_MEMORY_NfScene,
|
---|
142 | NX_MEMORY_NfRBSceneImage,
|
---|
143 | NX_MEMORY_NfShape,
|
---|
144 | NX_MEMORY_NfSyncManager,
|
---|
145 | NX_MEMORY_NfVRDBint,
|
---|
146 | NX_MEMORY_NfProfile,
|
---|
147 |
|
---|
148 | /* Fw DDI mallocs */
|
---|
149 | NX_MEMORY_NfShapePageTable,
|
---|
150 | NX_MEMORY_NfRBSwPipelinePCMTable,
|
---|
151 | NX_MEMORY_NfRBSwPipelineSendBuf,
|
---|
152 | NX_MEMORY_NfRBSwPipelineRecvBuf,
|
---|
153 | NX_MEMORY_NfSyncManagerMaterialBM,
|
---|
154 | NX_MEMORY_NfSyncManagerPrevAwakeBM,
|
---|
155 | NX_MEMORY_NfSyncManagerCurrAwakeBM,
|
---|
156 | NX_MEMORY_NfPageInstanceMapperInstancePool,
|
---|
157 | NX_MEMORY_NfConvexMapperConvexPool,
|
---|
158 | NX_MEMORY_NfRBDebugPipelinePCMTable,
|
---|
159 | NX_MEMORY_NFRBDebugPipelineComparatorTable,
|
---|
160 | NX_MEMORY_NvVRDContactBuffer,
|
---|
161 |
|
---|
162 | /* Fluid-DDI objects*/
|
---|
163 | NX_MEMORY_NfFluid,
|
---|
164 | NX_MEMORY_NfFluidTriangleMeshPPUInterfaceSw,
|
---|
165 | NX_MEMORY_NfFluidTriangleMeshPPUInterfaceHw,
|
---|
166 | NX_MEMORY_NfFluidPPUInterfaceSw,
|
---|
167 | NX_MEMORY_NfFluidPPUInterfaceHw,
|
---|
168 | NX_MEMORY_NfFluidIndexMap,
|
---|
169 | NX_MEMORY_NfFluidEmitter,
|
---|
170 | NX_MEMORY_ParticleArray,
|
---|
171 | NX_MEMORY_SiteData,
|
---|
172 | NX_MEMORY_NfShapeList,
|
---|
173 | NX_MEMORY_NxShapeList,
|
---|
174 | NX_MEMORY_DebugPacketHash,
|
---|
175 |
|
---|
176 | /* Fluid DDI mallocs */
|
---|
177 | NX_MEMORY_NfFluidControllerFW,
|
---|
178 | NX_MEMORY_NfFluidConvexFWArray,
|
---|
179 | NX_MEMORY_NfFluidMeshPacketHashPPU,
|
---|
180 | NX_MEMORY_NfFluidMeshTriangleVector,
|
---|
181 | NX_MEMORY_NfFluidParticleBuffer,
|
---|
182 | NX_MEMORY_NfFluidPacketTable,
|
---|
183 | NX_MEMORY_NfFluidVpePacketTable,
|
---|
184 | NX_MEMORY_NfFluidCellHashTable,
|
---|
185 | NX_MEMORY_NfFluidCellSumHashTable,
|
---|
186 | NX_MEMORY_NfFluidCellHashNode,
|
---|
187 | NX_MEMORY_NfFluidPacketHashNode,
|
---|
188 | NX_MEMORY_NfFluidUpdateBuffer,
|
---|
189 | NX_MEMORY_NfFluidConvexArrayElts,
|
---|
190 | NX_MEMORY_NfFluidMeshTriangleVectorElts,
|
---|
191 | NX_MEMORY_NfFluidMeshTriangleVectorElt,
|
---|
192 | NX_MEMORY_NfFluidMeshPktBucketVectorElts,
|
---|
193 | NX_MEMORY_NfFluidMeshPktNodeVectorElts,
|
---|
194 | NX_MEMORY_NfFluidPacketHashPackedData,
|
---|
195 | NX_MEMORY_NfFluidIDToIndexMap,
|
---|
196 | NX_MEMORY_NfFluidIndexToIDMap,
|
---|
197 | NX_MEMORY_NfFluidShapes,
|
---|
198 |
|
---|
199 | // ** NX_ALLOC calls
|
---|
200 | NX_MEMORY_CCD_TEMP,
|
---|
201 | NX_MEMORY_CONVEX_TEMP,
|
---|
202 | NX_MEMORY_TriangleMesh_TEMP,
|
---|
203 | NX_MEMORY_MINIBALL_TEMP,
|
---|
204 | NX_MEMORY_SMOOTH_NORMALS_TEMP,
|
---|
205 | NX_MEMORY_NxTriangle32,
|
---|
206 | NX_MEMORY_CCD_BUFFER,
|
---|
207 | NX_MEMORY_CCD_edgeDegenMap,
|
---|
208 | NX_MEMORY_InternalTriangleMesh_NxPoint,
|
---|
209 | NX_MEMORY_InternalTriangleMesh_NxTriangle32,
|
---|
210 | NX_MEMORY_InternalTriangleMesh_NxMaterialIndex,
|
---|
211 | NX_MEMORY_InternalTriangleMesh_faceRemap,
|
---|
212 | NX_MEMORY_InternalTriangelMesh_Plane,
|
---|
213 | NX_MEMORY_InternalTriangleMesh_Normals,
|
---|
214 | NX_MEMORY_InternalTriangleMesh_NxU8,
|
---|
215 | NX_MEMORY_InternalTriangleMesh_NxU16,
|
---|
216 | NX_MEMORY_InternalTriangleMesh_NxU32,
|
---|
217 | NX_MEMORY_NxSpringDesc,
|
---|
218 | NX_MEMORY_Scene_vertexTagStamps,
|
---|
219 | NX_MEMORY_Scene_featureCache,
|
---|
220 | NX_MEMORY_Scene_featureCacheExternal,
|
---|
221 | NX_MEMORY_TriangleMesh_NxU16,
|
---|
222 | NX_MEMORY_TriangleMesh_NxU8,
|
---|
223 | NX_MEMORY_PMAP,
|
---|
224 | NX_MEMORY_GenericCache_NxU8,
|
---|
225 | NX_MEMORY_PairManager_NxU32,
|
---|
226 | NX_MEMORY_PairManager_userPair,
|
---|
227 | NX_MEMORY_Utilities_FaceNormals,
|
---|
228 | NX_MEMORY_NxMutexRep,
|
---|
229 | NX_MEMORY_Generic_Array_Container,
|
---|
230 | NX_MEMORY_ConvexMesh,
|
---|
231 | // ** Ice Calls!
|
---|
232 | ICE_MEMORY_PERSISTENT,
|
---|
233 | ICE_MEMORY_TEMP,
|
---|
234 | ICE_MEMORY_SweepAndPrune,
|
---|
235 | ICE_MEMORY_Valencies,
|
---|
236 | ICE_MEMORY_ValenciesBuilder,
|
---|
237 | ICE_MEMORY_IndexedTriangle16,
|
---|
238 | ICE_MEMORY_HullPolygon,
|
---|
239 | ICE_MEMORY_Edge,
|
---|
240 | ICE_MEMORY_EdgeDesc,
|
---|
241 | ICE_MEMORY_CollisionHull,
|
---|
242 | ICE_MEMORY_SupportVertexMap,
|
---|
243 | ICE_MEMORY_RaycastMap,
|
---|
244 | ICE_MEMORY_MeshModel,
|
---|
245 | ICE_MEMORY_EdgeTriangle,
|
---|
246 | ICE_MEMORY_AdjTriangle,
|
---|
247 | ICE_MEMORY_AdjacenciesBuilder,
|
---|
248 | ICE_MEMORY_EdgeListBuilder,
|
---|
249 | ICE_MEMORY_LinearLooseOctree,
|
---|
250 | ICE_MEMORY_OctreeCell,
|
---|
251 | ICE_MEMORY_FreePruner,
|
---|
252 | ICE_MEMORY_DynamicPruner,
|
---|
253 | ICE_MEMORY_StaticPruner,
|
---|
254 | ICE_MEMORY_DynamicPruner2,
|
---|
255 | ICE_MEMORY_AABBTree,
|
---|
256 | ICE_MEMORY_AABBNoLeafTree,
|
---|
257 | ICE_MEMORY_AABBTreeNode,
|
---|
258 | ICE_MEMORY_AABBQuantizedNoLeafTree,
|
---|
259 | ICE_MEMORY_AABBCollisionTree,
|
---|
260 | ICE_MEMORY_PRUNING_SORTER,
|
---|
261 | ICE_MEMORY_AABBCollisionNode,
|
---|
262 | ICE_MEMORY_AABBNoLeafNode,
|
---|
263 | ICE_MEMORY_AABBQuantizedNode,
|
---|
264 | ICE_MEMORY_SAP_Element,
|
---|
265 | ICE_MEMORY_SAP_Box,
|
---|
266 | ICE_MEMORY_SAP_EndPoint,
|
---|
267 | ICE_MEMORY_CustomCell,
|
---|
268 | ICE_MEMORY_HandleManager,
|
---|
269 | ICE_MEMORY_AABBQuantizedNoLeafNode,
|
---|
270 | ICE_MEMORY_LeafTriangles,
|
---|
271 | ICE_MEMORY_Pair,
|
---|
272 | // Ice discrete allocations
|
---|
273 | ICE_MEMORY_ConvexDecomposer_FlatTags,
|
---|
274 | ICE_MEMORY_ConvexDecomposer_ConvexTags,
|
---|
275 | ICE_MEMORY_CookingUtils_XRef,
|
---|
276 | ICE_MEMORY_CookingUtils_RVerts,
|
---|
277 | ICE_MEMORY_CookingUtils_FaceNormals,
|
---|
278 | ICE_MEMORY_CookingUtils_VertexNormals,
|
---|
279 | ICE_MEMORY_ConvexHull_HullVertices,
|
---|
280 | ICE_MEMORY_ConvexHull_HullNormals,
|
---|
281 | ICE_MEMORY_ConvexHull_VertexData,
|
---|
282 | ICE_MEMORY_ConvexHull_EdgeData,
|
---|
283 | ICE_MEMORY_ConvexHull_EdgeNormals,
|
---|
284 | ICE_MEMORY_ConvexHull_FacesByEdges,
|
---|
285 | ICE_MEMORY_EdgeList_FacesByEdges,
|
---|
286 | ICE_MEMORY_EdgeList_ActiveEdges,
|
---|
287 | ICE_MEMORY_IceHullGaussMaps_Samples,
|
---|
288 | ICE_MEMORY_Valency_Valencies,
|
---|
289 | ICE_MEMORY_Valency_Offsets,
|
---|
290 | ICE_MEMORY_Valency_AdjecentVerts,
|
---|
291 | ICE_MEMORY_IcePruningPool_WorldBoxes,
|
---|
292 | ICE_MEMORY_IcePruningPool_Objects,
|
---|
293 | ICE_MEMORY_OPC_AABBTree_Indices,
|
---|
294 | ICE_MEMORY_OPC_HybridModel_Indices,
|
---|
295 | ICE_MEMORY_OPC_SweepAndPrune_Array,
|
---|
296 | ICE_MEMORY_IceContainer_NewEntries,
|
---|
297 | ICE_MEMORY_IceCustomArray_CellAddy,
|
---|
298 | ICE_MEMORY_IceHandleManager_Objects,
|
---|
299 | ICE_MEMORY_IceHandleManager_OutToIn,
|
---|
300 | ICE_MEMORY_IceHandleManager_InToOut,
|
---|
301 | ICE_MEMORY_IceHandleManager_Stamps,
|
---|
302 | ICE_MEMORY_IceRevisedRadix_Histogram,
|
---|
303 | ICE_MEMORY_IceRevistedRadix_Offset,
|
---|
304 | ICE_MEMORY_IceRevistedRadix_Ranks,
|
---|
305 | ICE_MEMORY_IceRevistedRadix_Ranks2,
|
---|
306 |
|
---|
307 | NX_MEMORY_LAST
|
---|
308 | };
|
---|
309 |
|
---|
310 | #if defined(_DEBUG)
|
---|
311 | #define NX_NEW_TMP(x) new((const char *)__FILE__, __LINE__, #x, NX_MEMORY_##x) x
|
---|
312 | #define NX_NEW(x) new((const char *)__FILE__, __LINE__, #x, NX_MEMORY_##x) x
|
---|
313 | #define NX_NEW_MEM(x,y) new((const char *)__FILE__, __LINE__, #x, NX_MEMORY_##y) x
|
---|
314 | #else
|
---|
315 | #define NX_NEW_TMP(x) new(NX_MEMORY_##x) x
|
---|
316 | #define NX_NEW(x) new(NX_MEMORY_##x) x
|
---|
317 | #define NX_NEW_MEM(x,y) new(NX_MEMORY_##y) x
|
---|
318 | #endif
|
---|
319 |
|
---|
320 | /**
|
---|
321 | \brief Abstract base class for an application defined memory allocator that can be used by the Nx library.
|
---|
322 |
|
---|
323 | <b>Threading:</b> All methods of this class should be thread safe as it can be called from the user thread or the physics processing thread(s).
|
---|
324 |
|
---|
325 | <h2>Example</h2>
|
---|
326 |
|
---|
327 | \include NxUserAllocator_Example.cpp
|
---|
328 | */
|
---|
329 | class NxUserAllocator
|
---|
330 | {
|
---|
331 | public:
|
---|
332 |
|
---|
333 | /**
|
---|
334 | \brief Allocates size bytes of memory.
|
---|
335 |
|
---|
336 | Same as simple #malloc below, but with extra debug info fields.
|
---|
337 |
|
---|
338 | <b>Threading:</b> This function should be thread safe as it can be called in the context of the user thread
|
---|
339 | and physics processing thread(s).
|
---|
340 |
|
---|
341 | \param size Number of bytes to allocate.
|
---|
342 | \param fileName File which is allocating the memory.
|
---|
343 | \param line Line which is allocating the memory.
|
---|
344 | \return The allocated block of memory.
|
---|
345 | */
|
---|
346 | virtual void* mallocDEBUG(size_t size, const char* fileName, int line) = 0;
|
---|
347 |
|
---|
348 | /**
|
---|
349 | \brief Allocates size bytes of memory.
|
---|
350 |
|
---|
351 | Same as simple #malloc below, but with extra debug info fields.
|
---|
352 |
|
---|
353 | <b>Threading:</b> This function should be thread safe as it can be called in the context of the user thread
|
---|
354 | and physics processing thread(s).
|
---|
355 |
|
---|
356 | \param size Number of bytes to allocate.
|
---|
357 | \param fileName File which is allocating the memory.
|
---|
358 | \param line Line which is allocating the memory.
|
---|
359 | \param className Name of the class which is allocating the memory.
|
---|
360 | \param type A hint about what the memory will be used for. See #NxMemoryType.
|
---|
361 | \return The allocated block of memory.
|
---|
362 | */
|
---|
363 | virtual void* mallocDEBUG(size_t size, const char* fileName, int line, const char* className, NxMemoryType type)
|
---|
364 | {
|
---|
365 | return mallocDEBUG(size, fileName, line); // Just so we don't break user code
|
---|
366 | }
|
---|
367 |
|
---|
368 | /**
|
---|
369 | \brief Allocates size bytes of memory.
|
---|
370 |
|
---|
371 | Compatible with the standard C malloc(), with the exception that
|
---|
372 | it should never return NULL. If you run out of memory, then
|
---|
373 | you should terminate the app or take some other appropriate action.
|
---|
374 |
|
---|
375 | <b>Threading:</b> This function should be thread safe as it can be called in the context of the user thread
|
---|
376 | and physics processing thread(s).
|
---|
377 |
|
---|
378 | \param size Number of bytes to allocate.
|
---|
379 | \return The allocated block of memory.
|
---|
380 | */
|
---|
381 | virtual void* malloc(size_t size) = 0;
|
---|
382 |
|
---|
383 | /**
|
---|
384 | \brief Allocates size bytes of memory.
|
---|
385 |
|
---|
386 | Compatible with the standard C malloc(), with the exception that
|
---|
387 | it should never return NULL. If you run out of memory, then
|
---|
388 | you should terminate the app or take some other appropriate action.
|
---|
389 |
|
---|
390 | <b>Threading:</b> This function should be thread safe as it can be called in the context of the user thread
|
---|
391 | and physics processing thread(s).
|
---|
392 |
|
---|
393 | \param size Number of bytes to allocate.
|
---|
394 | \param type A hint about what the memory will be used for. See #NxMemoryType.
|
---|
395 | \return The allocated block of memory.
|
---|
396 | */
|
---|
397 | virtual void* malloc(size_t size, NxMemoryType type)
|
---|
398 | {
|
---|
399 | return malloc(size); // Just so we don't break user code
|
---|
400 | }
|
---|
401 |
|
---|
402 | /**
|
---|
403 | \brief Resizes the memory block previously allocated with malloc() or
|
---|
404 | realloc() to be size() bytes, and returns the possibly moved memory.
|
---|
405 |
|
---|
406 | Compatible with the standard C realloc(), with the exception that
|
---|
407 | it should never return NULL. If you run out of memory, then
|
---|
408 | you should terminate the app or take some other appropriate action.
|
---|
409 |
|
---|
410 | <b>Threading:</b> This function should be thread safe as it can be called in the context of the user thread
|
---|
411 | and physics processing thread(s).
|
---|
412 |
|
---|
413 | \param memory Memory block to change the size of.
|
---|
414 | \param size New size for memory block.
|
---|
415 | \return New pointer to the block of memory.
|
---|
416 | */
|
---|
417 | virtual void* realloc(void* memory, size_t size) = 0;
|
---|
418 |
|
---|
419 | /**
|
---|
420 | \brief Frees the memory previously allocated by malloc() or realloc().
|
---|
421 |
|
---|
422 | Compatible with the standard C free().
|
---|
423 |
|
---|
424 | <b>Threading:</b> This function should be thread safe as it can be called in the context of the user thread
|
---|
425 | and physics processing thread(s).
|
---|
426 |
|
---|
427 | \param memory Memory to free.
|
---|
428 | */
|
---|
429 | virtual void free(void* memory) = 0;
|
---|
430 |
|
---|
431 | /**
|
---|
432 | \brief Verify heap.
|
---|
433 |
|
---|
434 | <b>Threading:</b> This function should be thread safe as it can be called in the context of the user thread
|
---|
435 | and physics processing thread(s).
|
---|
436 | */
|
---|
437 | virtual void checkDEBUG(void) {};
|
---|
438 |
|
---|
439 | };
|
---|
440 |
|
---|
441 | /** @} */
|
---|
442 | #endif
|
---|
443 |
|
---|
444 |
|
---|
445 | //AGCOPYRIGHTBEGIN
|
---|
446 | ///////////////////////////////////////////////////////////////////////////
|
---|
447 | // Copyright © 2005 AGEIA Technologies.
|
---|
448 | // All rights reserved. www.ageia.com
|
---|
449 | ///////////////////////////////////////////////////////////////////////////
|
---|
450 | //AGCOPYRIGHTEND
|
---|
451 |
|
---|