From d2760b18aa0363899b81d87726eaa63f85d66174 Mon Sep 17 00:00:00 2001 From: "erwin.coumans" Date: Thu, 4 Sep 2008 18:54:14 +0000 Subject: [PATCH] fix placement new[], see discussion here: http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1787&p=10252#p10252 --- .../BroadphaseCollision/btAxisSweep3.h | 3 ++- src/LinearMath/btScalar.h | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/BulletCollision/BroadphaseCollision/btAxisSweep3.h b/src/BulletCollision/BroadphaseCollision/btAxisSweep3.h index b807ddd9e..8964e422b 100644 --- a/src/BulletCollision/BroadphaseCollision/btAxisSweep3.h +++ b/src/BulletCollision/BroadphaseCollision/btAxisSweep3.h @@ -52,7 +52,7 @@ public: }; public: - ATTRIBUTE_ALIGNED16(class) Handle : public btBroadphaseProxy + class Handle : public btBroadphaseProxy { public: BT_DECLARE_ALIGNED_ALLOCATOR(); @@ -274,6 +274,7 @@ m_invalidPair(0) // allocate handles buffer and put all handles on free list m_pHandlesRawPtr = btAlignedAlloc(sizeof(Handle)*maxHandles,16); m_pHandles = new(m_pHandlesRawPtr) Handle[maxHandles]; + btAssert(m_pHandlesRawPtr==m_pHandles); //placement new[] should just return the same pointer m_maxHandles = maxHandles; m_numHandles = 0; diff --git a/src/LinearMath/btScalar.h b/src/LinearMath/btScalar.h index 1fee626d0..e2eb42e1d 100644 --- a/src/LinearMath/btScalar.h +++ b/src/LinearMath/btScalar.h @@ -145,11 +145,16 @@ typedef float btScalar; #endif + #define BT_DECLARE_ALIGNED_ALLOCATOR() \ - SIMD_FORCE_INLINE void* operator new(size_t sizeInBytes) { return btAlignedAlloc(sizeInBytes,16); } \ - SIMD_FORCE_INLINE void operator delete(void* ptr) { btAlignedFree(ptr); } \ - SIMD_FORCE_INLINE void* operator new(size_t, void* ptr) { return ptr; } \ - SIMD_FORCE_INLINE void operator delete(void*, void*) { } \ + SIMD_FORCE_INLINE void* operator new(size_t sizeInBytes) { return btAlignedAlloc(sizeInBytes,16); } \ + SIMD_FORCE_INLINE void operator delete(void* ptr) { btAlignedFree(ptr); } \ + SIMD_FORCE_INLINE void* operator new(size_t, void* ptr) { return ptr; } \ + SIMD_FORCE_INLINE void operator delete(void*, void*) { } \ + SIMD_FORCE_INLINE void* operator new[](size_t sizeInBytes) { return btAlignedAlloc(sizeInBytes,16); } \ + SIMD_FORCE_INLINE void operator delete[](void* ptr) { btAlignedFree(ptr); } \ + SIMD_FORCE_INLINE void* operator new[](size_t, void* ptr) { return ptr; } \ + SIMD_FORCE_INLINE void operator delete[](void*, void*) { } \