From 67b402b74fa8b1c353ef97119f61734afb85d557 Mon Sep 17 00:00:00 2001 From: Peter Slattery Date: Fri, 22 Nov 2019 23:57:30 -0800 Subject: [PATCH] Got assemblies to unload again --- src/foldhaus_app.cpp | 17 +++++++---------- src/gs_win32.cpp | 7 ++++++- todo.txt | 6 ++++-- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/foldhaus_app.cpp b/src/foldhaus_app.cpp index e36da86..3f4e58f 100644 --- a/src/foldhaus_app.cpp +++ b/src/foldhaus_app.cpp @@ -167,19 +167,18 @@ LoadAssembly (app_state* State, context Context, char* Path) internal void UnloadAssembly (s32 AssemblyIndex, app_state* State, context Context) { - assembly Assembly = State->AssemblyList[AssemblyIndex]; - /* - s32 LEDsInAssembly = Assembly.LEDBuffer->Count; - s32 MemoryRequiredForAssembly = CalculateMemorySizeForAssembly(LEDsInAssembly, Assembly.Name.Length); - Context.PlatformFree((u8*)Assembly.LEDBuffer, MemoryRequiredForAssembly); - - State->TotalLEDsCount -= LEDsInAssembly; - */ + assembly* Assembly = State->AssemblyList + AssemblyIndex; + State->TotalLEDsCount -= Assembly->LEDCount; + Context.PlatformFree(Assembly->Arena.Base, Assembly->Arena.Size); if (AssemblyIndex != (State->AssembliesCount - 1)) { State->AssemblyList[AssemblyIndex] = State->AssemblyList[State->AssembliesCount - 1]; } + else + { + *Assembly = {}; + } State->AssembliesCount -= 1; } @@ -339,8 +338,6 @@ HandleInput (app_state* State, input_queue InputQueue, mouse_state Mouse) ActiveCommands = State->Modes.ActiveModes[State->Modes.ActiveModesCount - 1].Commands; } - - for (s32 EventIdx = 0; EventIdx < InputQueue.QueueUsed; EventIdx++) { input_entry Event = InputQueue.Entries[EventIdx]; diff --git a/src/gs_win32.cpp b/src/gs_win32.cpp index 9b1277e..277b1aa 100644 --- a/src/gs_win32.cpp +++ b/src/gs_win32.cpp @@ -601,7 +601,12 @@ PLATFORM_ALLOC(Win32Alloc) PLATFORM_FREE(Win32Free) { - b32 Result = VirtualFree(Base, Size, MEM_RELEASE); + b32 Result = VirtualFree(Base, 0, MEM_RELEASE); + if (!Result) + { + s32 Error = WSAGetLastError(); + InvalidCodePath; + } return Result; } diff --git a/todo.txt b/todo.txt index a057795..d48682e 100644 --- a/todo.txt +++ b/todo.txt @@ -4,9 +4,11 @@ YOU WERE IN THE MIDDLE OF Assembly -> SACN interface -- you need to rebuild the map from leds -> universes -- - thinking about storing a sparse array of { led_start_index, led_count, led_universe, led_channel } +x you need to rebuild the map from leds -> universes +- x thinking about storing a sparse array of { led_start_index, led_count, led_universe, led_channel } - that we can iterate over to populate dmx buffers +- need to create a data structure in CreateDMXBuffers that prevents duplication of DMXBuffers. +- - thinking about a dictionary. Key is Universe, length is 256, create parallel arrays as necessary BUGS - Typing a period into a float value doesn't register. Problem here is that we arent' translating key presses into characters at the win32 layer. Need to do that.