From d1b874b3919ca614f96c9f170b93c81507e0123a Mon Sep 17 00:00:00 2001 From: belliash Date: Sat, 21 Jul 2018 14:44:36 +0200 Subject: [PATCH] Fix segmentation fault --- engine/lib/heap.c | 32 -------------------------------- engine/lib/memory.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 32 deletions(-) delete mode 100644 engine/lib/heap.c diff --git a/engine/lib/heap.c b/engine/lib/heap.c deleted file mode 100644 index f6b1484..0000000 --- a/engine/lib/heap.c +++ /dev/null @@ -1,32 +0,0 @@ -#include "ph7int.h" -#if defined(__WINNT__) - #include -#else - #include -#endif - -void *SyOSHeapAlloc(sxu32 nByte) { - void *pNew; -#if defined(__WINNT__) - pNew = HeapAlloc(GetProcessHeap(), 0, nByte); -#else - pNew = malloc((size_t)nByte); -#endif - return pNew; -} -void *SyOSHeapRealloc(void *pOld, sxu32 nByte) { - void *pNew; -#if defined(__WINNT__) - pNew = HeapReAlloc(GetProcessHeap(), 0, pOld, nByte); -#else - pNew = realloc(pOld, (size_t)nByte); -#endif - return pNew; -} -void SyOSHeapFree(void *pPtr) { -#if defined(__WINNT__) - HeapFree(GetProcessHeap(), 0, pPtr); -#else - free(pPtr); -#endif -} \ No newline at end of file diff --git a/engine/lib/memory.c b/engine/lib/memory.c index b054ebd..4839bb5 100644 --- a/engine/lib/memory.c +++ b/engine/lib/memory.c @@ -1,5 +1,36 @@ +#if defined(__WINNT__) + #include +#else + #include +#endif + #include "ph7int.h" +static void *SyOSHeapAlloc(sxu32 nByte) { + void *pNew; +#if defined(__WINNT__) + pNew = HeapAlloc(GetProcessHeap(), 0, nByte); +#else + pNew = malloc((size_t)nByte); +#endif + return pNew; +} +static void *SyOSHeapRealloc(void *pOld, sxu32 nByte) { + void *pNew; +#if defined(__WINNT__) + pNew = HeapReAlloc(GetProcessHeap(), 0, pOld, nByte); +#else + pNew = realloc(pOld, (size_t)nByte); +#endif + return pNew; +} +static void SyOSHeapFree(void *pPtr) { +#if defined(__WINNT__) + HeapFree(GetProcessHeap(), 0, pPtr); +#else + free(pPtr); +#endif +} PH7_PRIVATE void SyZero(void *pSrc, sxu32 nSize) { register unsigned char *zSrc = (unsigned char *)pSrc; unsigned char *zEnd;