diff --git a/include/assimp/allocator.h b/include/assimp/allocator.h index 35de1b911..0462cfc2b 100644 --- a/include/assimp/allocator.h +++ b/include/assimp/allocator.h @@ -45,19 +45,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include typedef void* (*alloc_func)(size_t size); -typedef void* (*realloc_func)(void* ptr, size_t size); typedef void (*free_func)(void* ptr); struct Allocator { - alloc_func alloc{nullptr}; - realloc_func realloc{nullptr}; - free_func free{nullptr}; + static alloc_func alloc{nullptr}; + static free_func free{nullptr}; + + static void init(alloc_func alloc_fn, free_func free_fn) { + alloc = alloc_fn; + free = free_fn; + } }; +static void aiRegisterAllocator(alloc_func alloc_fn, free_func free_fn) { + Allocator::init(alloc_fn, free_fn); +} + #define AI_NEW(ai_type,...) new ai_type(__VA_ARGS__) #define AI_NEW_ARRAY(ai_type,count) new ai_type[count]() #define AI_DELETE(ptr) delete ptr #define AI_DELETE_ARRAY(ptr) delete[] ptr #endif // AI_ALLOCATOR_H_INC -