Text archives Help
- From: bigler@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1536 - trunk/Core/Util
- Date: Mon, 23 Jul 2007 17:45:40 -0600 (MDT)
Author: bigler
Date: Mon Jul 23 17:45:40 2007
New Revision: 1536
Modified:
trunk/Core/Util/AlignedAllocator.h
Log:
Core/Util/AlignedAllocator.h
Overload the new[] and delete[] operators. This helps the
ApproximatePriorityQueue not blow up when seeding with SSE.
Modified: trunk/Core/Util/AlignedAllocator.h
==============================================================================
--- trunk/Core/Util/AlignedAllocator.h (original)
+++ trunk/Core/Util/AlignedAllocator.h Mon Jul 23 17:45:40 2007
@@ -31,6 +31,7 @@
#include <stddef.h> // for size_t definition
#include <SCIRun/Core/Util/Assert.h>
+#include <SCIRun/Core/Exceptions/InternalError.h>
namespace Manta {
@@ -50,6 +51,20 @@
return allocateAligned(size, Alignment);
}
void operator delete (void * mem)
+ {
+ deallocateAligned(mem);
+ }
+ void * operator new[] (size_t size)
+ {
+ // Only the first item in the array will be aligned. If you
+ // structure is not a multiple of the alignment size, you will
+ // have unaligned addresses for subsequent elements in the array.
+ if (size > sizeof(ParentT))
+ if (sizeof(ParentT) % Alignment != 0)
+ throw SCIRun::InternalError("Attempting to allocate an array of
objects that cannot be aligned. Please make sizeof(ParentT) a multiple of
Alignment", __FILE__, __LINE__);
+ return allocateAligned(size, Alignment);
+ }
+ void operator delete[](void * mem)
{
deallocateAligned(mem);
}
- [MANTA] r1536 - trunk/Core/Util, bigler, 07/23/2007
Archive powered by MHonArc 2.6.16.