Skip to content
Snippets Groups Projects
Commit 2437e340 authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Fix a small alloc tracking bug with llspatialgroup

parent 504272ba
Branches
Tags
No related merge requests found
...@@ -41,13 +41,6 @@ class LLMutex ; ...@@ -41,13 +41,6 @@ class LLMutex ;
#define LL_CHECK_MEMORY #define LL_CHECK_MEMORY
#endif #endif
#if LL_WINDOWS
#define LL_ALIGN_OF __alignof
#else
#define LL_ALIGN_OF __align_of__
#endif
#if LL_WINDOWS #if LL_WINDOWS
#if ADDRESS_SIZE == 64 #if ADDRESS_SIZE == 64
#define LL_DEFAULT_HEAP_ALIGN 16 #define LL_DEFAULT_HEAP_ALIGN 16
......
...@@ -387,41 +387,41 @@ public: ...@@ -387,41 +387,41 @@ public:
S32 getMemFootprint() const { return mMemFootprint; } S32 getMemFootprint() const { return mMemFootprint; }
#endif #endif
void* operator new(size_t size) template<int CUSTOM_ALIGNMENT>
static void* aligned_new(size_t size)
{ {
#if LL_TRACE_ENABLED #if LL_TRACE_ENABLED
claim_alloc(sMemStat, size); claim_alloc(sMemStat, size);
#endif #endif
return ll_aligned_malloc<ALIGNMENT>(size); return ll_aligned_malloc<CUSTOM_ALIGNMENT>(size);
} }
template<int CUSTOM_ALIGNMENT> template<int CUSTOM_ALIGNMENT>
static void* aligned_new(size_t size) static void aligned_delete(void* ptr, size_t size)
{ {
#if LL_TRACE_ENABLED #if LL_TRACE_ENABLED
claim_alloc(sMemStat, size); disclaim_alloc(sMemStat, size);
#endif #endif
return ll_aligned_malloc<CUSTOM_ALIGNMENT>(size); ll_aligned_free<CUSTOM_ALIGNMENT>(ptr);
} }
void operator delete(void* ptr, size_t size) void* operator new(std::size_t size)
{ {
#if LL_TRACE_ENABLED #if LL_TRACE_ENABLED
disclaim_alloc(sMemStat, size); claim_alloc(sMemStat, size);
#endif #endif
ll_aligned_free<ALIGNMENT>(ptr); return ll_aligned_malloc<ALIGNMENT>(size);
} }
template<int CUSTOM_ALIGNMENT> void operator delete(void* ptr, std::size_t size)
static void aligned_delete(void* ptr, size_t size)
{ {
#if LL_TRACE_ENABLED #if LL_TRACE_ENABLED
disclaim_alloc(sMemStat, size); disclaim_alloc(sMemStat, size);
#endif #endif
ll_aligned_free<CUSTOM_ALIGNMENT>(ptr); ll_aligned_free<ALIGNMENT>(ptr);
} }
void* operator new [](size_t size) void* operator new[](std::size_t size)
{ {
#if LL_TRACE_ENABLED #if LL_TRACE_ENABLED
claim_alloc(sMemStat, size); claim_alloc(sMemStat, size);
...@@ -429,7 +429,7 @@ public: ...@@ -429,7 +429,7 @@ public:
return ll_aligned_malloc<ALIGNMENT>(size); return ll_aligned_malloc<ALIGNMENT>(size);
} }
void operator delete[](void* ptr, size_t size) void operator delete[](void* ptr, std::size_t size)
{ {
#if LL_TRACE_ENABLED #if LL_TRACE_ENABLED
disclaim_alloc(sMemStat, size); disclaim_alloc(sMemStat, size);
......
...@@ -197,28 +197,30 @@ class LLSpatialGroup : public LLOcclusionCullingGroup ...@@ -197,28 +197,30 @@ class LLSpatialGroup : public LLOcclusionCullingGroup
friend class LLOctreeStateCheck; friend class LLOctreeStateCheck;
public: public:
LLSpatialGroup(const LLSpatialGroup& rhs) = delete;
const LLSpatialGroup& operator=(const LLSpatialGroup& rhs) = delete;
// <alchemy> // <alchemy>
void* operator new(size_t size) void* operator new(std::size_t size)
{ {
return ll_aligned_malloc<64>(size); return aligned_new<64>(size);
} }
void operator delete(void* ptr) void operator delete(void* ptr, std::size_t size)
{ {
ll_aligned_free<64>(ptr); aligned_delete<64>(ptr, size);
} }
// </alchemy>
LLSpatialGroup(const LLSpatialGroup& rhs) : LLOcclusionCullingGroup(rhs) void* operator new[](std::size_t size)
{ {
*this = rhs; return aligned_new<64>(size);
} }
const LLSpatialGroup& operator=(const LLSpatialGroup& rhs) void operator delete[](void* ptr, std::size_t size)
{ {
LL_ERRS() << "Illegal operation!" << LL_ENDL; aligned_delete<64>(ptr, size);
return *this;
} }
// </alchemy>
static U32 sNodeCount; static U32 sNodeCount;
static BOOL sNoDelete; //deletion of spatial groups and draw info not allowed if TRUE static BOOL sNoDelete; //deletion of spatial groups and draw info not allowed if TRUE
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment