From 3d9851fbe25cfa9fb362a301642c468d5dac45cf Mon Sep 17 00:00:00 2001 From: Peter Slattery Date: Tue, 4 Feb 2020 23:35:21 -0800 Subject: [PATCH] More platform layer functions cleanup --- src/win32_foldhaus.cpp | 10 +++++----- src/win32_foldhaus_fileio.h | 12 ++---------- src/win32_foldhaus_memory.h | 14 ++++---------- 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/src/win32_foldhaus.cpp b/src/win32_foldhaus.cpp index e9074e4..2685f37 100644 --- a/src/win32_foldhaus.cpp +++ b/src/win32_foldhaus.cpp @@ -499,13 +499,13 @@ SetApplicationLinks (context* Context, win32_dll_refresh DLL, work_queue* WorkQu internal u8* DEBUGAlloc(s32 ElementSize, s32 ElementCount) { - return Win32BasicAlloc(ElementSize * ElementCount); + return Win32Alloc(ElementSize * ElementCount); } internal u8* Win32Realloc(u8* Buf, s32 OldSize, s32 NewSize) { - u8* NewMemory = Win32BasicAlloc(NewSize); + u8* NewMemory = Win32Alloc(NewSize); GSMemCopy(Buf, NewMemory, OldSize); return NewMemory; } @@ -613,7 +613,7 @@ WinMain ( if (HotLoadDLL(&DLLRefresh)) { SetApplicationLinks(&Context, DLLRefresh, &WorkQueue); - Context.ReloadStaticData(Context, GlobalDebugServices, Win32BasicAlloc, Win32Free); + Context.ReloadStaticData(Context, GlobalDebugServices, Win32Alloc, Win32Free); } else { @@ -627,7 +627,7 @@ WinMain ( u8* RenderMemory = Win32Alloc(RenderMemorySize); render_command_buffer RenderBuffer = AllocateRenderCommandBuffer(RenderMemory, RenderMemorySize, Win32Realloc); - Context.InitializeApplication(Context, Win32BasicAlloc, Win32Free); + Context.InitializeApplication(Context, Win32Alloc, Win32Free); Running = true; Context.WindowIsVisible = true; @@ -643,7 +643,7 @@ WinMain ( if (HotLoadDLL(&DLLRefresh)) { SetApplicationLinks(&Context, DLLRefresh, &WorkQueue); - Context.ReloadStaticData(Context, GlobalDebugServices, Win32BasicAlloc, Win32Free); + Context.ReloadStaticData(Context, GlobalDebugServices, Win32Alloc, Win32Free); } { // Mouse Position diff --git a/src/win32_foldhaus_fileio.h b/src/win32_foldhaus_fileio.h index ca4bed9..77e431c 100644 --- a/src/win32_foldhaus_fileio.h +++ b/src/win32_foldhaus_fileio.h @@ -13,20 +13,12 @@ PLATFORM_READ_ENTIRE_FILE(Win32ReadEntireFile) platform_memory_result Result = {}; Result.Error = PLATFORM_MEMORY_NO_ERROR; - HANDLE FileHandle = CreateFileA ( - Path, - GENERIC_READ, - 0, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); + HANDLE FileHandle = CreateFileA (Path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (FileHandle != INVALID_HANDLE_VALUE) { DWORD FileSize = GetFileSize(FileHandle, NULL); - Result.Base = (u8*)VirtualAlloc(NULL, FileSize, MEM_COMMIT | MEM_RESERVE, - PAGE_EXECUTE_READWRITE); + Result.Base = (u8*)VirtualAlloc(NULL, FileSize, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); if (Result.Base) { Result.Size = FileSize; diff --git a/src/win32_foldhaus_memory.h b/src/win32_foldhaus_memory.h index f36e01b..3afedcc 100644 --- a/src/win32_foldhaus_memory.h +++ b/src/win32_foldhaus_memory.h @@ -8,17 +8,11 @@ // #ifndef WIN32_FOLDHAUS_MEMORY_H -internal u8* -Win32BasicAlloc (s32 Size) -{ - return (u8*)VirtualAlloc(NULL, Size, - MEM_COMMIT | MEM_RESERVE, - PAGE_EXECUTE_READWRITE); -} - PLATFORM_ALLOC(Win32Alloc) { - u8* Result = Win32BasicAlloc(Size); + u8* Result = (u8*)VirtualAlloc(NULL, Size, + MEM_COMMIT | MEM_RESERVE, + PAGE_EXECUTE_READWRITE); return Result; } @@ -35,7 +29,7 @@ PLATFORM_FREE(Win32Free) PLATFORM_REALLOC(Win32Realloc) { - u8* NewMemory = Win32BasicAlloc(NewSize); + u8* NewMemory = Win32Alloc(NewSize); if (Base) { GSMemCopy(Base, NewMemory, OldSize);