diff options
author | BobTheBob9 <for.oliver.kirkham@gmail.com> | 2022-08-16 01:12:59 +0100 |
---|---|---|
committer | BobTheBob9 <for.oliver.kirkham@gmail.com> | 2022-08-16 01:12:59 +0100 |
commit | 082f3893215797268d7ac8c1000ebe371f276af7 (patch) | |
tree | b5cc677a49635a9244559e235d4915c064c9f6c4 /NorthstarDLL/memalloc.cpp | |
parent | b30a385fc25dad05e568ae8538f5aa3656c5c8d4 (diff) | |
download | NorthstarLauncher-082f3893215797268d7ac8c1000ebe371f276af7.tar.gz NorthstarLauncher-082f3893215797268d7ac8c1000ebe371f276af7.zip |
lots of stuff idk
Diffstat (limited to 'NorthstarDLL/memalloc.cpp')
-rw-r--r-- | NorthstarDLL/memalloc.cpp | 148 |
1 files changed, 74 insertions, 74 deletions
diff --git a/NorthstarDLL/memalloc.cpp b/NorthstarDLL/memalloc.cpp index d96b06a1..f16aaed0 100644 --- a/NorthstarDLL/memalloc.cpp +++ b/NorthstarDLL/memalloc.cpp @@ -1,74 +1,74 @@ -#include "pch.h"
-#include "memalloc.h"
-#include "tier0.h"
-
-using namespace Tier0;
-
-// TODO: rename to malloc and free after removing statically compiled .libs
-
-extern "C" void* _malloc_base(size_t n)
-{
- // allocate into static buffer if g_pMemAllocSingleton isn't initialised
- if (!g_pMemAllocSingleton)
- TryCreateGlobalMemAlloc();
-
- return g_pMemAllocSingleton->m_vtable->Alloc(g_pMemAllocSingleton, n);
-}
-
-/*extern "C" void* malloc(size_t n)
-{
- return _malloc_base(n);
-}*/
-
-extern "C" void _free_base(void* p)
-{
- if (!g_pMemAllocSingleton)
- TryCreateGlobalMemAlloc();
-
- g_pMemAllocSingleton->m_vtable->Free(g_pMemAllocSingleton, p);
-}
-
-extern "C" void* _realloc_base(void* oldPtr, size_t size)
-{
- if (!g_pMemAllocSingleton)
- TryCreateGlobalMemAlloc();
-
- return g_pMemAllocSingleton->m_vtable->Realloc(g_pMemAllocSingleton, oldPtr, size);
-}
-
-extern "C" void* _calloc_base(size_t n, size_t size)
-{
- size_t bytes = n * size;
- void* memory = _malloc_base(bytes);
- if (memory)
- {
- memset(memory, 0, bytes);
- }
- return memory;
-}
-
-extern "C" char* _strdup_base(const char* src)
-{
- char* str;
- char* p;
- int len = 0;
-
- while (src[len])
- len++;
- str = reinterpret_cast<char*>(_malloc_base(len + 1));
- p = str;
- while (*src)
- *p++ = *src++;
- *p = '\0';
- return str;
-}
-
-void* operator new(size_t n)
-{
- return _malloc_base(n);
-}
-
-void operator delete(void* p)
-{
- _free_base(p);
-} // /FORCE:MULTIPLE
\ No newline at end of file +#include "pch.h" +#include "memalloc.h" +#include "tier0.h" + +using namespace Tier0; + +// TODO: rename to malloc and free after removing statically compiled .libs + +extern "C" void* _malloc_base(size_t n) +{ + // allocate into static buffer if g_pMemAllocSingleton isn't initialised + if (!g_pMemAllocSingleton) + TryCreateGlobalMemAlloc(); + + return g_pMemAllocSingleton->m_vtable->Alloc(g_pMemAllocSingleton, n); +} + +/*extern "C" void* malloc(size_t n) +{ + return _malloc_base(n); +}*/ + +extern "C" void _free_base(void* p) +{ + if (!g_pMemAllocSingleton) + TryCreateGlobalMemAlloc(); + + g_pMemAllocSingleton->m_vtable->Free(g_pMemAllocSingleton, p); +} + +extern "C" void* _realloc_base(void* oldPtr, size_t size) +{ + if (!g_pMemAllocSingleton) + TryCreateGlobalMemAlloc(); + + return g_pMemAllocSingleton->m_vtable->Realloc(g_pMemAllocSingleton, oldPtr, size); +} + +extern "C" void* _calloc_base(size_t n, size_t size) +{ + size_t bytes = n * size; + void* memory = _malloc_base(bytes); + if (memory) + { + memset(memory, 0, bytes); + } + return memory; +} + +extern "C" char* _strdup_base(const char* src) +{ + char* str; + char* p; + int len = 0; + + while (src[len]) + len++; + str = reinterpret_cast<char*>(_malloc_base(len + 1)); + p = str; + while (*src) + *p++ = *src++; + *p = '\0'; + return str; +} + +void* operator new(size_t n) +{ + return _malloc_base(n); +} + +void operator delete(void* p) +{ + _free_base(p); +} // /FORCE:MULTIPLE |