mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Fully disable memory expansion
The game's memalloc does not support memory expansion, the base expansion function couldn't be shadowed properly without linker errors. However we want to make sure no instances of it get compiled into the module, ever. Therefore, the duplicate symbol is kept in memoverride (_expand_base), and the only usage has been removed from LZHAM's 'lzham_mem'. If a linkage is attempted to anything utilizing '_expand', a linker error will be emitted and no image will be generated.
This commit is contained in:
parent
46390ba875
commit
789ecbc234
12
r5dev/thirdparty/lzham/lzham_mem.cpp
vendored
12
r5dev/thirdparty/lzham/lzham_mem.cpp
vendored
@ -91,19 +91,9 @@ namespace lzham
|
||||
else
|
||||
{
|
||||
void* p_final_block = p;
|
||||
#ifdef WIN32
|
||||
p_new = _expand(p, size);
|
||||
#else
|
||||
|
||||
p_new = NULL;
|
||||
#endif
|
||||
|
||||
if (p_new)
|
||||
{
|
||||
LZHAM_ASSERT( (reinterpret_cast<ptr_bits_t>(p_new) & (LZHAM_MIN_ALLOC_ALIGNMENT - 1)) == 0 );
|
||||
p_final_block = p_new;
|
||||
}
|
||||
else if (movable)
|
||||
if (movable)
|
||||
{
|
||||
p_new = realloc(p, size);
|
||||
|
||||
|
@ -48,24 +48,6 @@ void operator delete(void* const pBlock) throw()
|
||||
return free(pBlock);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void* __cdecl _expand(void* const pBlock, size_t const nNewSize, int const nBlockUse)
|
||||
{
|
||||
// Expanding isn't supported!!!
|
||||
Assert(0);
|
||||
return NULL;
|
||||
}
|
||||
#if (defined(_DEBUG) || defined(USE_MEM_DEBUG))
|
||||
void* __cdecl _expand_dbg(void* pBlock, size_t nNewSize, int nBlockUse,
|
||||
const char* const pFileName, int nLine)
|
||||
{
|
||||
NOTE_UNUSED(pFileName);
|
||||
NOTE_UNUSED(nLine);
|
||||
|
||||
return _expand(pBlock, nNewSize, nBlockUse);
|
||||
}
|
||||
#endif // _DEBUG || USE_MEM_DEBUG
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
extern "C"
|
||||
{
|
||||
@ -128,6 +110,13 @@ extern "C"
|
||||
#endif // !_DEBUG && !USE_MEM_DEBUG
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
void* __cdecl _expand_base(void* const pBlock, size_t const nNewSize, int const nBlockUse)
|
||||
{
|
||||
// Expanding isn't supported!!!
|
||||
Assert(0);
|
||||
return NULL;
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
__declspec(noinline) size_t __cdecl _msize(void* const pBlock)
|
||||
{
|
||||
InitAllocator();
|
||||
@ -240,6 +229,15 @@ extern "C"
|
||||
MemAllocSingleton()->InternalFree(pBlock, "tier0_static128", 0);
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
void* __cdecl _expand_dbg(void* pBlock, size_t nNewSize, int nBlockUse,
|
||||
const char* const pFileName, int nLine)
|
||||
{
|
||||
NOTE_UNUSED(pFileName);
|
||||
NOTE_UNUSED(nLine);
|
||||
|
||||
return _expand_base(pBlock, nNewSize, nBlockUse);
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
__declspec(noinline) size_t __cdecl _msize_dbg(void* const pBlock, int const)
|
||||
{
|
||||
return _msize(pBlock);
|
||||
|
Loading…
x
Reference in New Issue
Block a user