Commit 8874a6ec authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/tests: Use the global memory allocation helpers.

parent 887836cc
......@@ -157,7 +157,7 @@ static void test_comboex(void)
*out_of_range_item = "Out of Range Item";
/* Allocate space for result */
textBuffer = HeapAlloc(GetProcessHeap(), 0, MAX_CHARS);
textBuffer = heap_alloc(MAX_CHARS);
/* Basic comboboxex test */
myHwnd = createComboEx(WS_BORDER | WS_VISIBLE | WS_CHILD | CBS_DROPDOWN);
......@@ -243,7 +243,7 @@ static void test_comboex(void)
/* Cleanup */
HeapFree(GetProcessHeap(), 0, textBuffer);
heap_free(textBuffer);
DestroyWindow(myHwnd);
}
......
......@@ -28,6 +28,7 @@
#include "winnls.h"
#include "commctrl.h"
#include "wine/heap.h"
#include "wine/test.h"
#include "v6util.h"
......@@ -156,11 +157,11 @@ static void run_test(const struct listbox_test test)
WCHAR *txtw;
CHAR *txt;
txt = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size + 1);
txt = heap_alloc_zero(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 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (size + 1) * sizeof(*txtw));
txtw = heap_alloc_zero((size + 1) * sizeof(*txtw));
resW = SendMessageW(hLB, LB_GETTEXT, i, (LPARAM)txtw);
if (resA != resW)
trace("SendMessageW(LB_GETTEXT) not supported on this platform (resA=%d resW=%d), skipping...\n", resA, resW);
......@@ -170,8 +171,8 @@ static void run_test(const struct listbox_test test)
ok(!strcmp (txt, strings[i]), "returned string for item %d does not match %s vs %s\n", i, txt, strings[i]);
}
HeapFree(GetProcessHeap(), 0, txtw);
HeapFree(GetProcessHeap(), 0, txt);
heap_free(txtw);
heap_free(txt);
}
/* Confirm the count of items, and that an invalid delete does not remove anything */
......
......@@ -28,6 +28,7 @@
#include "commctrl.h"
#include "shlwapi.h"
#include "wine/heap.h"
#include "wine/test.h"
/* Keys for testing MRU functions */
......@@ -120,7 +121,7 @@ static LSTATUS mru_RegDeleteTreeA(HKEY hKey, LPCSTR lpszSubKey)
if (dwMaxLen > sizeof(szNameBuf)/sizeof(CHAR))
{
/* Name too big: alloc a buffer for it */
if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(CHAR))))
if (!(lpszName = heap_alloc(dwMaxLen * sizeof(CHAR))))
{
ret = ERROR_NOT_ENOUGH_MEMORY;
goto cleanup;
......@@ -155,7 +156,7 @@ static LSTATUS mru_RegDeleteTreeA(HKEY hKey, LPCSTR lpszSubKey)
cleanup:
/* Free buffer if allocated */
if (lpszName != szNameBuf)
HeapFree( GetProcessHeap(), 0, lpszName);
heap_free(lpszName);
if(lpszSubKey)
RegCloseKey(hSubKey);
return ret;
......
......@@ -20,6 +20,7 @@
#include <assert.h>
#include <windows.h>
#include "wine/heap.h"
#include "wine/test.h"
/* undocumented SWP flags - from SDK 3.1 */
......@@ -68,16 +69,13 @@ static void add_message(struct msg_sequence **seq, int sequence_index,
if (!msg_seq->sequence)
{
msg_seq->size = 10;
msg_seq->sequence = HeapAlloc(GetProcessHeap(), 0,
msg_seq->size * sizeof (struct message));
msg_seq->sequence = heap_alloc(msg_seq->size * sizeof (*msg_seq->sequence));
}
if (msg_seq->count == msg_seq->size)
{
msg_seq->size *= 2;
msg_seq->sequence = HeapReAlloc(GetProcessHeap(), 0,
msg_seq->sequence,
msg_seq->size * sizeof (struct message));
msg_seq->sequence = heap_realloc(msg_seq->sequence, msg_seq->size * sizeof (*msg_seq->sequence));
}
assert(msg_seq->sequence);
......@@ -89,7 +87,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];
HeapFree(GetProcessHeap(), 0, msg_seq->sequence);
heap_free(msg_seq->sequence);
msg_seq->sequence = NULL;
msg_seq->count = msg_seq->size = 0;
}
......@@ -393,5 +391,5 @@ static void init_msg_sequences(struct msg_sequence **seq, int n)
int i;
for (i = 0; i < n; i++)
seq[i] = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct msg_sequence));
seq[i] = heap_alloc_zero(sizeof(*seq[i]));
}
......@@ -28,6 +28,7 @@
#include <commctrl.h>
#include <uxtheme.h>
#include "wine/heap.h"
#include "wine/test.h"
static BOOL (WINAPI *pImageList_Destroy)(HIMAGELIST);
......@@ -220,9 +221,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 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nRows*sizeof(int));
ret.cyRowHeights = heap_alloc_zero(nRows * sizeof(int));
ret.nBands = 0;
ret.bands = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nBands*sizeof(rbband_result_t));
ret.bands = heap_alloc_zero(nBands * sizeof(*ret.bands));
return ret;
}
......@@ -246,7 +247,7 @@ static rbsize_result_t *rbsize_results;
static void rbsize_results_init(void)
{
rbsize_results = HeapAlloc(GetProcessHeap(), 0, rbsize_results_num*sizeof(rbsize_result_t));
rbsize_results = heap_alloc(rbsize_results_num * sizeof(*rbsize_results));
rbsize_results[0] = rbsize_init(0, 0, 672, 0, 0, 0, 0);
......@@ -433,10 +434,10 @@ static void rbsize_results_free(void)
int i;
for (i = 0; i < rbsize_results_num; i++) {
HeapFree(GetProcessHeap(), 0, rbsize_results[i].cyRowHeights);
HeapFree(GetProcessHeap(), 0, rbsize_results[i].bands);
heap_free(rbsize_results[i].cyRowHeights);
heap_free(rbsize_results[i].bands);
}
HeapFree(GetProcessHeap(), 0, rbsize_results);
heap_free(rbsize_results);
rbsize_results = NULL;
}
......
......@@ -28,6 +28,7 @@
#include "winuser.h"
#include "commctrl.h"
#include "wine/heap.h"
#include "wine/test.h"
static BOOL (WINAPI *pSetWindowSubclass)(HWND, SUBCLASSPROC, UINT_PTR, DWORD_PTR);
......@@ -119,12 +120,12 @@ static void add_message(const struct message *msg)
if (!sequence)
{
sequence_size = 10;
sequence = HeapAlloc( GetProcessHeap(), 0, sequence_size * sizeof (struct message) );
sequence = heap_alloc( sequence_size * sizeof (struct message) );
}
if (sequence_cnt == sequence_size)
{
sequence_size *= 2;
sequence = HeapReAlloc( GetProcessHeap(), 0, sequence, sequence_size * sizeof (struct message) );
sequence = heap_realloc( sequence, sequence_size * sizeof (struct message) );
}
assert(sequence);
......@@ -136,8 +137,8 @@ static void add_message(const struct message *msg)
static void flush_sequence(void)
{
HeapFree(GetProcessHeap(), 0, sequence);
sequence = 0;
heap_free(sequence);
sequence = NULL;
sequence_cnt = sequence_size = 0;
}
......
......@@ -24,6 +24,7 @@
#include "winuser.h"
#include "commctrl.h"
#include "wine/heap.h"
#include "wine/test.h"
#include "v6util.h"
#include "msg.h"
......@@ -144,7 +145,7 @@ static void run_test_(TASKDIALOGCONFIG *info, int expect_button, const struct me
int i;
/* Allocate messages to test against, plus 2 implicit and 1 empty */
msg_start = msg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*msg) * (test_messages_len + 3));
msg_start = msg = heap_alloc_zero(sizeof(*msg) * (test_messages_len + 3));
/* Always needed, thus made implicit */
init_test_message(TDN_DIALOG_CONSTRUCTED, 0, 0, msg++);
......@@ -163,7 +164,7 @@ static void run_test_(TASKDIALOGCONFIG *info, int expect_button, const struct me
ok_(file, line)(ret_button == expect_button,
"Wrong button. Expected %d, got %d\n", expect_button, ret_button);
HeapFree(GetProcessHeap(), 0, msg_start);
heap_free(msg_start);
}
static const LONG_PTR test_ref_data = 123456;
......
......@@ -182,7 +182,7 @@ static LRESULT parent_wnd_notify(LPARAM lParam)
if (save->iItem == -1)
{
save->cbData = save->cbData * 2 + 11 * sizeof(DWORD);
save->pData = HeapAlloc( GetProcessHeap(), 0, save->cbData );
save->pData = heap_alloc( save->cbData );
save->pData[0] = 0xcafe;
save->pCurrent = save->pData + 1;
}
......@@ -258,7 +258,7 @@ static LRESULT parent_wnd_notify(LPARAM lParam)
if (restore->iItem == 0)
{
restore->tbButton.iString = (INT_PTR)HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, 8 );
restore->tbButton.iString = (INT_PTR)heap_alloc_zero( 8 );
strcpy( (char *)restore->tbButton.iString, "foo" );
}
else if (restore->iItem == 1)
......@@ -288,7 +288,7 @@ static LRESULT parent_wnd_notify(LPARAM lParam)
{
case 0:
tb->tbButton.idCommand = 7;
alloced_str = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, 8 );
alloced_str = heap_alloc_zero( 8 );
strcpy( alloced_str, "foo" );
tb->tbButton.iString = (INT_PTR)alloced_str;
return 1;
......@@ -1006,7 +1006,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 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nButtonsAlloc*sizeof(RECT));
ret.prcButtons = heap_alloc_zero(nButtonsAlloc * sizeof(*ret.prcButtons));
return ret;
}
......@@ -1028,7 +1028,7 @@ static void init_tbsize_results(void) {
int fontheight = system_font_height();
int buttonwidth;
tbsize_results = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, tbsize_results_num*sizeof(tbsize_result_t));
tbsize_results = heap_alloc_zero(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);
......@@ -1283,8 +1283,8 @@ static void free_tbsize_results(void) {
int i;
for (i = 0; i < tbsize_results_num; i++)
HeapFree(GetProcessHeap(), 0, tbsize_results[i].prcButtons);
HeapFree(GetProcessHeap(), 0, tbsize_results);
heap_free(tbsize_results[i].prcButtons);
heap_free(tbsize_results);
tbsize_results = NULL;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment