1/*
2 * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
3 *
4 * NVIDIA CORPORATION and its licensors retain all intellectual property
5 * and proprietary rights in and to this software, related documentation
6 * and any modifications thereto. Any use, reproduction, disclosure or
7 * distribution of this software and related documentation without an express
8 * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 */
10// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
11// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
12
13
14#ifndef PX_FOUNDATION_PX_ALLOCATOR_CALLBACK_H
15#define PX_FOUNDATION_PX_ALLOCATOR_CALLBACK_H
16
17/** \addtogroup foundation
18@{
19*/
20
21#include "foundation/Px.h"
22#ifndef PX_DOXYGEN
23namespace physx
24{
25#endif
26
27/**
28\brief Abstract base class for an application defined memory allocator that can be used by the Px library.
29
30\note The SDK state should not be modified from within any allocation/free function.
31
32<b>Threading:</b> All methods of this class should be thread safe as it can be called from the user thread
33or the physics processing thread(s).
34*/
35
36class PxAllocatorCallback
37{
38public:
39
40 /**
41 \brief destructor
42 */
43 virtual ~PxAllocatorCallback() {}
44
45 /**
46 \brief Allocates size bytes of memory, which must be 16-byte aligned.
47
48 This method should never return NULL. If you run out of memory, then
49 you should terminate the app or take some other appropriate action.
50
51 <b>Threading:</b> This function should be thread safe as it can be called in the context of the user thread
52 and physics processing thread(s).
53
54 \param size Number of bytes to allocate.
55 \param typeName Name of the datatype that is being allocated
56 \param filename The source file which allocated the memory
57 \param line The source line which allocated the memory
58 \return The allocated block of memory.
59 */
60 virtual void* allocate(size_t size, const char* typeName, const char* filename, int line) = 0;
61
62 /**
63 \brief Frees memory previously allocated by allocate().
64
65 <b>Threading:</b> This function should be thread safe as it can be called in the context of the user thread
66 and physics processing thread(s).
67
68 \param ptr Memory to free.
69 */
70 virtual void deallocate(void* ptr) = 0;
71};
72
73#ifndef PX_DOXYGEN
74} // namespace physx
75#endif
76
77/** @} */
78#endif
79