From fa1ac0dfc9eaebe6fdd7621f9b1e6be2cfba9a3e Mon Sep 17 00:00:00 2001 From: freedom7341 Date: Wed, 11 Oct 2023 10:17:34 -0600 Subject: [PATCH] i wanna work on this on my desktop --- progmgr/group.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/progmgr/group.c b/progmgr/group.c index 173acf5..1dfbf34 100644 --- a/progmgr/group.c +++ b/progmgr/group.c @@ -98,6 +98,15 @@ HWND CreateGroup(_In_ PGROUP pg) // allocate memory for a new group pGroup = (PGROUP)malloc(CalculateGroupMemory(pg, 0)); + if (pGroup == NULL) + return NULL; + + // clean up the memory if it's valid + ZeroMemory(pGroup, CalculateGroupMemory(pg, 0)); + + // copy over the group structure + *pGroup = *pg; + // TODO: get group minimized/maximized flags mcs.szClass = szGrpClass; @@ -190,23 +199,29 @@ PITEM CreateItem(_In_ HWND hWndGroup, _In_ PITEM pi) LVITEM lvi = { 0 }; PGROUP pGroup = NULL; PITEM pItem = NULL; + UINT uiTest = 0; // we actually just want the group pointer lol pGroup = (PGROUP)GetWindowLongPtr(hWndGroup, GWLP_USERDATA); + uiTest = pGroup->cItemArray; + // return NULL if we can't get to the group or item if (hWndGroup == NULL) return NULL; if (pGroup == NULL) return NULL; - if (pi == NULL) return NULL; // compare group's existing memory to needed memory // if needed, reallocate the group's memory if (_msize(pGroup) != CalculateGroupMemory(pGroup, 1)) - SetWindowLongPtr(hWndGroup, GWLP_USERDATA, (LONG_PTR)realloc(pGroup, CalculateGroupMemory(pGroup, 1))); + { + // if we reallocate memory then send the new pointer in + if (realloc(pGroup, CalculateGroupMemory(pGroup, 1)) != NULL) + SetWindowLongPtr(hWndGroup, GWLP_USERDATA, (LONG_PTR)pGroup); + } // add the item pItem = pGroup->pItemArray + pGroup->cItemArray;