diff --git a/microstack/ILibParsers.c b/microstack/ILibParsers.c index 2d205b4..d3c297c 100644 --- a/microstack/ILibParsers.c +++ b/microstack/ILibParsers.c @@ -1278,9 +1278,10 @@ ILibExportMethod void* ILibMemory_GetExtraMemory(void *container, size_t contain size_t ILibMemory_GetExtraMemorySize(void* extraMemory) { if (extraMemory == NULL) { return 0; } - return(((size_t*)((char*)extraMemory - sizeof(size_t)))[0]); + return(ILibMemory_Legacy_GetExtraSizePtr(extraMemory)[0]); } + ILibChain_Link* ILibChain_Link_Allocate(size_t structSize, size_t extraMemorySize) { ILibChain_Link *retVal; diff --git a/microstack/ILibParsers.h b/microstack/ILibParsers.h index 10ce10c..b7903b9 100644 --- a/microstack/ILibParsers.h +++ b/microstack/ILibParsers.h @@ -489,6 +489,10 @@ int ILibIsRunningOnChainThread(void* chain); void* ILibMemory_SmartReAllocate(void *ptr, size_t len); void* ILibMemory_SmartAllocateEx_ResizeExtra(void *ptr, size_t extraSize); + #define ILibMemory_Legacy_RawSize(containerSize, extraSize) (containerSize + extraSize + sizeof(size_t)) + #define ILibMemory_Legacy_GetExtraSizePtr(extra) ((size_t*)(((char*)extra)-sizeof(size_t))) + #define ILibMemory_Legacy_GetExtraSizePtrEx(container, containerSize) ILibMemory_Legacy_GetExtraSizePtr(ILibMemory_GetExtraMemory(container, containerSize)) + void ILibMemory_SecureZero(void *ptr, size_t len); void ILibMemory_Free(void *ptr); void* ILibMemory_AllocateTemp(void* chain, size_t sz);