summaryrefslogtreecommitdiffstats
path: root/LibOVR/Src/Kernel/OVR_Allocator.cpp
diff options
context:
space:
mode:
authorBrad Davis <[email protected]>2013-07-03 09:16:03 -0700
committerBrad Davis <[email protected]>2013-07-03 09:16:03 -0700
commitd46694c91c2bec4eb1e282c0c0101e6dab26e082 (patch)
treeeb5fba71edf1aedc0d6af9406881004289433b20 /LibOVR/Src/Kernel/OVR_Allocator.cpp
parent7fa8be4bc565adc9911c95c814480cc48bf2d13c (diff)
SDK 0.2.3
Diffstat (limited to 'LibOVR/Src/Kernel/OVR_Allocator.cpp')
-rw-r--r--LibOVR/Src/Kernel/OVR_Allocator.cpp168
1 files changed, 84 insertions, 84 deletions
diff --git a/LibOVR/Src/Kernel/OVR_Allocator.cpp b/LibOVR/Src/Kernel/OVR_Allocator.cpp
index 1f17ffe..ec9a877 100644
--- a/LibOVR/Src/Kernel/OVR_Allocator.cpp
+++ b/LibOVR/Src/Kernel/OVR_Allocator.cpp
@@ -1,84 +1,84 @@
-/************************************************************************************
-
-Filename : OVR_Allocator.cpp
-Content : Installable memory allocator implementation
-Created : September 19, 2012
-Notes :
-
-Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
-
-Use of this software is subject to the terms of the Oculus license
-agreement provided at the time of installation or download, or which
-otherwise accompanies this software in either electronic or hard copy form.
-
-************************************************************************************/
-
-#include "OVR_Allocator.h"
-#ifdef OVR_OS_MAC
- #include <stdlib.h>
-#else
- #include <malloc.h>
-#endif
-
-namespace OVR {
-
-//-----------------------------------------------------------------------------------
-// ***** Allocator
-
-Allocator* Allocator::pInstance = 0;
-
-// Default AlignedAlloc implementation will delegate to Alloc/Free after doing rounding.
-void* Allocator::AllocAligned(UPInt size, UPInt align)
-{
- OVR_ASSERT((align & (align-1)) == 0);
- align = (align > sizeof(UPInt)) ? align : sizeof(UPInt);
- UPInt p = (UPInt)Alloc(size+align);
- UPInt aligned = 0;
- if (p)
- {
- aligned = (UPInt(p) + align-1) & ~(align-1);
- if (aligned == p)
- aligned += align;
- *(((UPInt*)aligned)-1) = aligned-p;
- }
- return (void*)aligned;
-}
-
-void Allocator::FreeAligned(void* p)
-{
- UPInt src = UPInt(p) - *(((UPInt*)p)-1);
- Free((void*)src);
-}
-
-
-//------------------------------------------------------------------------
-// ***** Default Allocator
-
-// This allocator is created and used if no other allocator is installed.
-// Default allocator delegates to system malloc.
-
-void* DefaultAllocator::Alloc(UPInt size)
-{
- return malloc(size);
-}
-void* DefaultAllocator::AllocDebug(UPInt size, const char* file, unsigned line)
-{
-#if defined(OVR_CC_MSVC) && defined(_CRTDBG_MAP_ALLOC)
- return _malloc_dbg(size, _NORMAL_BLOCK, file, line);
-#else
- OVR_UNUSED2(file, line);
- return malloc(size);
-#endif
-}
-
-void* DefaultAllocator::Realloc(void* p, UPInt newSize)
-{
- return realloc(p, newSize);
-}
-void DefaultAllocator::Free(void *p)
-{
- return free(p);
-}
-
-
-} // OVR
+/************************************************************************************
+
+Filename : OVR_Allocator.cpp
+Content : Installable memory allocator implementation
+Created : September 19, 2012
+Notes :
+
+Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
+
+Use of this software is subject to the terms of the Oculus license
+agreement provided at the time of installation or download, or which
+otherwise accompanies this software in either electronic or hard copy form.
+
+************************************************************************************/
+
+#include "OVR_Allocator.h"
+#ifdef OVR_OS_MAC
+ #include <stdlib.h>
+#else
+ #include <malloc.h>
+#endif
+
+namespace OVR {
+
+//-----------------------------------------------------------------------------------
+// ***** Allocator
+
+Allocator* Allocator::pInstance = 0;
+
+// Default AlignedAlloc implementation will delegate to Alloc/Free after doing rounding.
+void* Allocator::AllocAligned(UPInt size, UPInt align)
+{
+ OVR_ASSERT((align & (align-1)) == 0);
+ align = (align > sizeof(UPInt)) ? align : sizeof(UPInt);
+ UPInt p = (UPInt)Alloc(size+align);
+ UPInt aligned = 0;
+ if (p)
+ {
+ aligned = (UPInt(p) + align-1) & ~(align-1);
+ if (aligned == p)
+ aligned += align;
+ *(((UPInt*)aligned)-1) = aligned-p;
+ }
+ return (void*)aligned;
+}
+
+void Allocator::FreeAligned(void* p)
+{
+ UPInt src = UPInt(p) - *(((UPInt*)p)-1);
+ Free((void*)src);
+}
+
+
+//------------------------------------------------------------------------
+// ***** Default Allocator
+
+// This allocator is created and used if no other allocator is installed.
+// Default allocator delegates to system malloc.
+
+void* DefaultAllocator::Alloc(UPInt size)
+{
+ return malloc(size);
+}
+void* DefaultAllocator::AllocDebug(UPInt size, const char* file, unsigned line)
+{
+#if defined(OVR_CC_MSVC) && defined(_CRTDBG_MAP_ALLOC)
+ return _malloc_dbg(size, _NORMAL_BLOCK, file, line);
+#else
+ OVR_UNUSED2(file, line);
+ return malloc(size);
+#endif
+}
+
+void* DefaultAllocator::Realloc(void* p, UPInt newSize)
+{
+ return realloc(p, newSize);
+}
+void DefaultAllocator::Free(void *p)
+{
+ return free(p);
+}
+
+
+} // OVR