The global operator override new
looks unsafe.
#571
Replies: 1 comment 1 reply
-
(I'm not a Jolt developer, just some random user of Jolt.) Jolt overrides the JoltPhysics/Jolt/Core/Memory.h Lines 28 to 37 in ad9cd40 Which you'll find is used in JoltPhysics/Jolt/Physics/Body/Body.h Lines 32 to 35 in ad9cd40 The functions that are used in this macro can be set by the user through these global function pointers: JoltPhysics/Jolt/Core/Memory.h Lines 19 to 23 in ad9cd40 Which in examples like JoltPhysics/Jolt/Core/Memory.cpp Lines 63 to 69 in ad9cd40 You can find an example of me hooking up mimalloc to Jolt here. |
Beta Was this translation helpful? Give feedback.
-
Hello, while integrating a library based on the Jolt Physics; I've noticed that it uses
new
to create theBody
objects https://github.com/jrouwe/JoltPhysics/blob/master/Jolt/Physics/Body/BodyManager.cpp#L148-L157.Therefore, the
new
operator can be overridden to provide a custom allocator, to eventually support linear allocation.The issue is that the global-override-
new
is not confined into the library, rather it s global per executable. It means that the rest of the application, where my library will be used, will also use thenew
defined by my library: this is unsafe and undesired.I wonder if would be possible to switch to an Allocator solution, instead to rely on
new
.Please, let me know if my understanding on how it works is wrong.
Beta Was this translation helpful? Give feedback.
All reactions