[PATCH v2 0/1] MR4247: comctl32/tests: Use CRT allocation functions.
-- v2: comctl32/tests: Use CRT allocation functions. https://gitlab.winehq.org/wine/wine/-/merge_requests/4247
From: Alex Henrie <alexhenrie24(a)gmail.com> --- dlls/comctl32/tests/combo.c | 4 ++-- dlls/comctl32/tests/listbox.c | 9 ++++----- dlls/comctl32/tests/mru.c | 5 ++--- dlls/comctl32/tests/msg.h | 9 ++++----- dlls/comctl32/tests/rebar.c | 13 ++++++------- dlls/comctl32/tests/subclass.c | 7 +++---- dlls/comctl32/tests/taskdialog.c | 5 ++--- dlls/comctl32/tests/toolbar.c | 18 +++++++----------- 8 files changed, 30 insertions(+), 40 deletions(-) diff --git a/dlls/comctl32/tests/combo.c b/dlls/comctl32/tests/combo.c index 3eceeb55bd5..4a58b8763a4 100644 --- a/dlls/comctl32/tests/combo.c +++ b/dlls/comctl32/tests/combo.c @@ -161,7 +161,7 @@ static void test_comboex(void) *out_of_range_item = "Out of Range Item"; /* Allocate space for result */ - textBuffer = heap_alloc(MAX_CHARS); + textBuffer = malloc(MAX_CHARS); /* Basic comboboxex test */ myHwnd = createComboEx(WS_BORDER | WS_VISIBLE | WS_CHILD | CBS_DROPDOWN); @@ -247,7 +247,7 @@ static void test_comboex(void) /* Cleanup */ - heap_free(textBuffer); + free(textBuffer); DestroyWindow(myHwnd); } diff --git a/dlls/comctl32/tests/listbox.c b/dlls/comctl32/tests/listbox.c index cb311b1fc77..16c546852a1 100644 --- a/dlls/comctl32/tests/listbox.c +++ b/dlls/comctl32/tests/listbox.c @@ -27,7 +27,6 @@ #include "winnls.h" #include "commctrl.h" -#include "wine/heap.h" #include "wine/test.h" #include "v6util.h" #include "msg.h" @@ -254,18 +253,18 @@ static void run_test(DWORD style, const struct listbox_test test) WCHAR *txtw; CHAR *txt; - txt = heap_alloc_zero(size + 1); + txt = calloc(1, size + 1); resA = SendMessageA(hLB, LB_GETTEXT, i, (LPARAM)txt); ok(!strcmp(txt, strings[i]), "returned string for item %d does not match %s vs %s\n", i, txt, strings[i]); - txtw = heap_alloc_zero((size + 1) * sizeof(*txtw)); + txtw = calloc(size + 1, sizeof(*txtw)); resW = SendMessageW(hLB, LB_GETTEXT, i, (LPARAM)txtw); ok(resA == resW, "Unexpected text length.\n"); WideCharToMultiByte(CP_ACP, 0, txtw, -1, txt, size, NULL, NULL); ok(!strcmp (txt, strings[i]), "Unexpected string for item %d, %s vs %s.\n", i, txt, strings[i]); - heap_free(txtw); - heap_free(txt); + free(txtw); + free(txt); } /* Confirm the count of items, and that an invalid delete does not remove anything */ diff --git a/dlls/comctl32/tests/mru.c b/dlls/comctl32/tests/mru.c index 472fb99bac3..a2caf5f078a 100644 --- a/dlls/comctl32/tests/mru.c +++ b/dlls/comctl32/tests/mru.c @@ -28,7 +28,6 @@ #include "commctrl.h" #include "shlwapi.h" -#include "wine/heap.h" #include "wine/test.h" /* Keys for testing MRU functions */ @@ -121,7 +120,7 @@ static LSTATUS mru_RegDeleteTreeA(HKEY hKey, LPCSTR lpszSubKey) if (dwMaxLen > ARRAY_SIZE(szNameBuf)) { /* Name too big: alloc a buffer for it */ - if (!(lpszName = heap_alloc(dwMaxLen * sizeof(CHAR)))) + if (!(lpszName = malloc(dwMaxLen * sizeof(CHAR)))) { ret = ERROR_NOT_ENOUGH_MEMORY; goto cleanup; @@ -156,7 +155,7 @@ static LSTATUS mru_RegDeleteTreeA(HKEY hKey, LPCSTR lpszSubKey) cleanup: /* Free buffer if allocated */ if (lpszName != szNameBuf) - heap_free(lpszName); + free(lpszName); if(lpszSubKey) RegCloseKey(hSubKey); return ret; diff --git a/dlls/comctl32/tests/msg.h b/dlls/comctl32/tests/msg.h index 16a8f6e92eb..76bf5450b2f 100644 --- a/dlls/comctl32/tests/msg.h +++ b/dlls/comctl32/tests/msg.h @@ -20,7 +20,6 @@ #include <assert.h> #include <windows.h> -#include "wine/heap.h" #include "wine/test.h" /* undocumented SWP flags - from SDK 3.1 */ @@ -71,13 +70,13 @@ static void add_message(struct msg_sequence **seq, int sequence_index, if (!msg_seq->sequence) { msg_seq->size = 10; - msg_seq->sequence = heap_alloc(msg_seq->size * sizeof (*msg_seq->sequence)); + msg_seq->sequence = malloc(msg_seq->size * sizeof (*msg_seq->sequence)); } if (msg_seq->count == msg_seq->size) { msg_seq->size *= 2; - msg_seq->sequence = heap_realloc(msg_seq->sequence, msg_seq->size * sizeof (*msg_seq->sequence)); + msg_seq->sequence = realloc(msg_seq->sequence, msg_seq->size * sizeof (*msg_seq->sequence)); } assert(msg_seq->sequence); @@ -89,7 +88,7 @@ static void add_message(struct msg_sequence **seq, int sequence_index, static inline void flush_sequence(struct msg_sequence **seg, int sequence_index) { struct msg_sequence *msg_seq = seg[sequence_index]; - heap_free(msg_seq->sequence); + free(msg_seq->sequence); msg_seq->sequence = NULL; msg_seq->count = msg_seq->size = 0; } @@ -394,5 +393,5 @@ static void init_msg_sequences(struct msg_sequence **seq, int n) int i; for (i = 0; i < n; i++) - seq[i] = heap_alloc_zero(sizeof(*seq[i])); + seq[i] = calloc(1, sizeof(*seq[i])); } diff --git a/dlls/comctl32/tests/rebar.c b/dlls/comctl32/tests/rebar.c index c15b22aeca1..7cafa4ba52b 100644 --- a/dlls/comctl32/tests/rebar.c +++ b/dlls/comctl32/tests/rebar.c @@ -22,7 +22,6 @@ #include <windows.h> #include <commctrl.h> -#include "wine/heap.h" #include "wine/test.h" static BOOL (WINAPI *pImageList_Destroy)(HIMAGELIST); @@ -215,9 +214,9 @@ static rbsize_result_t rbsize_init(int cleft, int ctop, int cright, int cbottom, SetRect(&ret.rcClient, cleft, ctop, cright, cbottom); ret.cyBarHeight = cyBarHeight; ret.nRows = 0; - ret.cyRowHeights = heap_alloc_zero(nRows * sizeof(int)); + ret.cyRowHeights = calloc(nRows, sizeof(int)); ret.nBands = 0; - ret.bands = heap_alloc_zero(nBands * sizeof(*ret.bands)); + ret.bands = calloc(nBands, sizeof(*ret.bands)); return ret; } @@ -241,7 +240,7 @@ static rbsize_result_t *rbsize_results; static void rbsize_results_init(void) { - rbsize_results = heap_alloc(rbsize_results_num * sizeof(*rbsize_results)); + rbsize_results = malloc(rbsize_results_num * sizeof(*rbsize_results)); rbsize_results[0] = rbsize_init(0, 0, 672, 0, 0, 0, 0); @@ -428,10 +427,10 @@ static void rbsize_results_free(void) int i; for (i = 0; i < rbsize_results_num; i++) { - heap_free(rbsize_results[i].cyRowHeights); - heap_free(rbsize_results[i].bands); + free(rbsize_results[i].cyRowHeights); + free(rbsize_results[i].bands); } - heap_free(rbsize_results); + free(rbsize_results); rbsize_results = NULL; } diff --git a/dlls/comctl32/tests/subclass.c b/dlls/comctl32/tests/subclass.c index bc3fc6f1d91..73e7288e8a2 100644 --- a/dlls/comctl32/tests/subclass.c +++ b/dlls/comctl32/tests/subclass.c @@ -26,7 +26,6 @@ #include "winuser.h" #include "commctrl.h" -#include "wine/heap.h" #include "wine/test.h" static BOOL (WINAPI *pGetWindowSubclass)(HWND, SUBCLASSPROC, UINT_PTR, DWORD_PTR *); @@ -124,12 +123,12 @@ static void add_message(const struct message *msg) if (!sequence) { sequence_size = 10; - sequence = heap_alloc( sequence_size * sizeof (struct message) ); + sequence = malloc(sequence_size * sizeof(struct message)); } if (sequence_cnt == sequence_size) { sequence_size *= 2; - sequence = heap_realloc( sequence, sequence_size * sizeof (struct message) ); + sequence = realloc(sequence, sequence_size * sizeof(struct message)); } assert(sequence); @@ -141,7 +140,7 @@ static void add_message(const struct message *msg) static void flush_sequence(void) { - heap_free(sequence); + free(sequence); sequence = NULL; sequence_cnt = sequence_size = 0; } diff --git a/dlls/comctl32/tests/taskdialog.c b/dlls/comctl32/tests/taskdialog.c index 6a12b185639..ef60a5953bd 100644 --- a/dlls/comctl32/tests/taskdialog.c +++ b/dlls/comctl32/tests/taskdialog.c @@ -24,7 +24,6 @@ #include "winuser.h" #include "commctrl.h" -#include "wine/heap.h" #include "wine/test.h" #include "v6util.h" #include "msg.h" @@ -404,7 +403,7 @@ static void run_test_(TASKDIALOGCONFIG *info, int expect_button, int expect_radi int i; /* Allocate messages to test against, plus 2 implicit and 1 empty */ - msg_start = msg = heap_alloc_zero(sizeof(*msg) * (test_messages_len + 3)); + msg_start = msg = calloc(test_messages_len + 3, sizeof(*msg)); /* Always needed, thus made implicit */ init_test_message(TDN_DIALOG_CONSTRUCTED, 0, 0, msg++); @@ -425,7 +424,7 @@ static void run_test_(TASKDIALOGCONFIG *info, int expect_button, int expect_radi ok_(file, line)(ret_radio == expect_radio_button, "Wrong radio button. Expected %d, got %d\n", expect_radio_button, ret_radio); - heap_free(msg_start); + free(msg_start); } static const LONG_PTR test_ref_data = 123456; diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c index 7c886e1f88f..f2a69d869c1 100644 --- a/dlls/comctl32/tests/toolbar.c +++ b/dlls/comctl32/tests/toolbar.c @@ -226,7 +226,7 @@ static LRESULT parent_wnd_notify(LPARAM lParam) if (save->iItem == -1) { save->cbData = save->cbData * 2 + 11 * sizeof(DWORD); - save->pData = heap_alloc( save->cbData ); + save->pData = malloc(save->cbData); save->pData[0] = 0xcafe; save->pCurrent = save->pData + 1; } @@ -301,10 +301,7 @@ static LRESULT parent_wnd_notify(LPARAM lParam) restore->tbButton.dwData = restore->iItem; if (restore->iItem == 0) - { - restore->tbButton.iString = (INT_PTR)heap_alloc_zero( 8 ); - strcpy( (char *)restore->tbButton.iString, "foo" ); - } + restore->tbButton.iString = (INT_PTR)strdup( "foo" ); else if (restore->iItem == 1) restore->tbButton.iString = 2; else @@ -332,8 +329,7 @@ static LRESULT parent_wnd_notify(LPARAM lParam) { case 0: tb->tbButton.idCommand = 7; - alloced_str = heap_alloc_zero( 8 ); - strcpy( alloced_str, "foo" ); + alloced_str = strdup( "foo" ); tb->tbButton.iString = (INT_PTR)alloced_str; return 1; case 1: @@ -1077,7 +1073,7 @@ static tbsize_result_t init_tbsize_result(int nButtonsAlloc, int cleft, int ctop ret.szMin.cx = minx; ret.szMin.cy = miny; ret.nButtons = 0; - ret.prcButtons = heap_alloc_zero(nButtonsAlloc * sizeof(*ret.prcButtons)); + ret.prcButtons = calloc(nButtonsAlloc, sizeof(*ret.prcButtons)); return ret; } @@ -1099,7 +1095,7 @@ static void init_tbsize_results(void) { int fontheight = system_font_height(); int buttonwidth; - tbsize_results = heap_alloc_zero(tbsize_results_num * sizeof(*tbsize_results)); + tbsize_results = calloc(tbsize_results_num, sizeof(*tbsize_results)); tbsize_results[0] = init_tbsize_result(5, 0, 0 ,672 ,26, 100 ,22); tbsize_addbutton(&tbsize_results[0], 0, 2, 23, 24); @@ -1357,8 +1353,8 @@ static void free_tbsize_results(void) { int i; for (i = 0; i < tbsize_results_num; i++) - heap_free(tbsize_results[i].prcButtons); - heap_free(tbsize_results); + free(tbsize_results[i].prcButtons); + free(tbsize_results); tbsize_results = NULL; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4247
Hi, It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated. The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=139472 Your paranoid android. === build (build log) === /home/winetest/tools/testbot/var/wine-exe32/../wine/dlls/comctl32/tests/pager.c:273: undefined reference to `heap_alloc' collect2: error: ld returned 1 exit status Task: The exe32 Wine build failed === debian11 (build log) === /home/winetest/tools/testbot/var/wine-win32/../wine/dlls/comctl32/tests/pager.c:273: undefined reference to `heap_alloc' /home/winetest/tools/testbot/var/wine-win32/../wine/dlls/comctl32/tests/pager.c:273: undefined reference to `heap_alloc' collect2: error: ld returned 1 exit status collect2: error: ld returned 1 exit status Task: The win32 Wine build failed === debian11b (build log) === /home/winetest/tools/testbot/var/wine-wow64/../wine/dlls/comctl32/tests/pager.c:273: undefined reference to `heap_alloc' collect2: error: ld returned 1 exit status /home/winetest/tools/testbot/var/wine-wow64/../wine/dlls/comctl32/tests/pager.c:273: undefined reference to `heap_alloc' collect2: error: ld returned 1 exit status Task: The wow64 Wine build failed
Note that this doesn't pass CI. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4247#note_50768
participants (4)
-
Alex Henrie -
Alex Henrie (@alexhenrie) -
Marvin -
Zhiyi Zhang (@zhiyi)