Commit 0b7eed03 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

gdi32/tests: Use CRT allocation functions.

parent ffdbd835
...@@ -285,13 +285,13 @@ static void test_GdiConvertToDevmodeW(void) ...@@ -285,13 +285,13 @@ static void test_GdiConvertToDevmodeW(void)
dmW = pGdiConvertToDevmodeW(&dmA); dmW = pGdiConvertToDevmodeW(&dmA);
ok(dmW->dmSize >= FIELD_OFFSET(DEVMODEW, dmICMMethod), "dmSize is too small: %04x\n", dmW->dmSize); ok(dmW->dmSize >= FIELD_OFFSET(DEVMODEW, dmICMMethod), "dmSize is too small: %04x\n", dmW->dmSize);
ok(dmW->dmSize <= sizeof(DEVMODEW), "dmSize is too large: %04x\n", dmW->dmSize); ok(dmW->dmSize <= sizeof(DEVMODEW), "dmSize is too large: %04x\n", dmW->dmSize);
HeapFree(GetProcessHeap(), 0, dmW); free(dmW);
dmA.dmSize = FIELD_OFFSET(DEVMODEA, dmFields) + sizeof(dmA.dmFields); dmA.dmSize = FIELD_OFFSET(DEVMODEA, dmFields) + sizeof(dmA.dmFields);
dmW = pGdiConvertToDevmodeW(&dmA); dmW = pGdiConvertToDevmodeW(&dmA);
ok(dmW->dmSize == FIELD_OFFSET(DEVMODEW, dmFields) + sizeof(dmW->dmFields), ok(dmW->dmSize == FIELD_OFFSET(DEVMODEW, dmFields) + sizeof(dmW->dmFields),
"wrong size %u\n", dmW->dmSize); "wrong size %u\n", dmW->dmSize);
HeapFree(GetProcessHeap(), 0, dmW); free(dmW);
dmA.dmICMMethod = DMICMMETHOD_NONE; dmA.dmICMMethod = DMICMMETHOD_NONE;
dmA.dmSize = FIELD_OFFSET(DEVMODEA, dmICMMethod) + sizeof(dmA.dmICMMethod); dmA.dmSize = FIELD_OFFSET(DEVMODEA, dmICMMethod) + sizeof(dmA.dmICMMethod);
...@@ -300,13 +300,13 @@ static void test_GdiConvertToDevmodeW(void) ...@@ -300,13 +300,13 @@ static void test_GdiConvertToDevmodeW(void)
"wrong size %u\n", dmW->dmSize); "wrong size %u\n", dmW->dmSize);
ok(dmW->dmICMMethod == DMICMMETHOD_NONE, ok(dmW->dmICMMethod == DMICMMETHOD_NONE,
"expected DMICMMETHOD_NONE, got %lu\n", dmW->dmICMMethod); "expected DMICMMETHOD_NONE, got %lu\n", dmW->dmICMMethod);
HeapFree(GetProcessHeap(), 0, dmW); free(dmW);
dmA.dmSize = 1024; dmA.dmSize = 1024;
dmW = pGdiConvertToDevmodeW(&dmA); dmW = pGdiConvertToDevmodeW(&dmA);
ok(dmW->dmSize == FIELD_OFFSET(DEVMODEW, dmPanningHeight) + sizeof(dmW->dmPanningHeight), ok(dmW->dmSize == FIELD_OFFSET(DEVMODEW, dmPanningHeight) + sizeof(dmW->dmPanningHeight),
"wrong size %u\n", dmW->dmSize); "wrong size %u\n", dmW->dmSize);
HeapFree(GetProcessHeap(), 0, dmW); free(dmW);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
dmA.dmSize = 0; dmA.dmSize = 0;
...@@ -319,7 +319,7 @@ static void test_GdiConvertToDevmodeW(void) ...@@ -319,7 +319,7 @@ static void test_GdiConvertToDevmodeW(void)
dmW = pGdiConvertToDevmodeW(&dmA); dmW = pGdiConvertToDevmodeW(&dmA);
ok(dmW->dmSize == FIELD_OFFSET(DEVMODEW, dmFields), ok(dmW->dmSize == FIELD_OFFSET(DEVMODEW, dmFields),
"expected %04lx, got %04x\n", FIELD_OFFSET(DEVMODEW, dmFields), dmW->dmSize); "expected %04lx, got %04x\n", FIELD_OFFSET(DEVMODEW, dmFields), dmW->dmSize);
HeapFree(GetProcessHeap(), 0, dmW); free(dmW);
} }
static void test_device_caps( HDC hdc, HDC ref_dc, const char *descr, int scale ) static void test_device_caps( HDC hdc, HDC ref_dc, const char *descr, int scale )
...@@ -1361,11 +1361,11 @@ static HDC create_printer_dc(int scale, BOOL reset) ...@@ -1361,11 +1361,11 @@ static HDC create_printer_dc(int scale, BOOL reset)
if (!pOpenPrinterA( buffer, &hprn, NULL )) goto done; if (!pOpenPrinterA( buffer, &hprn, NULL )) goto done;
pGetPrinterA( hprn, 2, NULL, 0, &len ); pGetPrinterA( hprn, 2, NULL, 0, &len );
pbuf = HeapAlloc( GetProcessHeap(), 0, len ); pbuf = malloc( len );
if (!pGetPrinterA( hprn, 2, (LPBYTE)pbuf, len, &len )) goto done; if (!pGetPrinterA( hprn, 2, (LPBYTE)pbuf, len, &len )) goto done;
pGetPrinterDriverA( hprn, NULL, 3, NULL, 0, &len ); pGetPrinterDriverA( hprn, NULL, 3, NULL, 0, &len );
dbuf = HeapAlloc( GetProcessHeap(), 0, len ); dbuf = malloc( len );
if (!pGetPrinterDriverA( hprn, NULL, 3, (LPBYTE)dbuf, len, &len )) goto done; if (!pGetPrinterDriverA( hprn, NULL, 3, (LPBYTE)dbuf, len, &len )) goto done;
pbuf->pDevMode->dmScale = scale; pbuf->pDevMode->dmScale = scale;
...@@ -1378,8 +1378,8 @@ static HDC create_printer_dc(int scale, BOOL reset) ...@@ -1378,8 +1378,8 @@ static HDC create_printer_dc(int scale, BOOL reset)
if (reset) ResetDCA( hdc, pbuf->pDevMode ); if (reset) ResetDCA( hdc, pbuf->pDevMode );
done: done:
HeapFree( GetProcessHeap(), 0, dbuf ); free( dbuf );
HeapFree( GetProcessHeap(), 0, pbuf ); free( pbuf );
if (hprn) pClosePrinter( hprn ); if (hprn) pClosePrinter( hprn );
if (winspool) FreeLibrary( winspool ); if (winspool) FreeLibrary( winspool );
if (!hdc) skip( "could not create a DC for the default printer\n" ); if (!hdc) skip( "could not create a DC for the default printer\n" );
......
...@@ -1354,10 +1354,10 @@ static void reset_bits( HDC hdc, const BITMAPINFO *bmi, BYTE *bits ) ...@@ -1354,10 +1354,10 @@ static void reset_bits( HDC hdc, const BITMAPINFO *bmi, BYTE *bits )
if (bits) memset( bits, 0xcc, size ); if (bits) memset( bits, 0xcc, size );
else else
{ {
void *ddb_bits = HeapAlloc( GetProcessHeap(), 0, size ); void *ddb_bits = malloc( size );
memset( ddb_bits, 0xcc, size ); memset( ddb_bits, 0xcc, size );
SetBitmapBits( GetCurrentObject(hdc, OBJ_BITMAP), size, ddb_bits ); SetBitmapBits( GetCurrentObject(hdc, OBJ_BITMAP), size, ddb_bits );
HeapFree( GetProcessHeap(), 0, ddb_bits ); free( ddb_bits );
} }
} }
...@@ -1377,10 +1377,10 @@ static char *hash_dib(HDC hdc, const BITMAPINFO *bmi, const void *bits) ...@@ -1377,10 +1377,10 @@ static char *hash_dib(HDC hdc, const BITMAPINFO *bmi, const void *bits)
if (!bits) if (!bits)
{ {
void *ddb_bits = HeapAlloc( GetProcessHeap(), 0, dib_size ); void *ddb_bits = malloc(dib_size);
GetBitmapBits( GetCurrentObject(hdc, OBJ_BITMAP), dib_size, ddb_bits ); GetBitmapBits(GetCurrentObject(hdc, OBJ_BITMAP), dib_size, ddb_bits);
CryptHashData(hash, ddb_bits, dib_size, 0); CryptHashData(hash, ddb_bits, dib_size, 0);
HeapFree( GetProcessHeap(), 0, ddb_bits ); free(ddb_bits);
} }
else CryptHashData(hash, bits, dib_size, 0); else CryptHashData(hash, bits, dib_size, 0);
...@@ -1390,7 +1390,7 @@ static char *hash_dib(HDC hdc, const BITMAPINFO *bmi, const void *bits) ...@@ -1390,7 +1390,7 @@ static char *hash_dib(HDC hdc, const BITMAPINFO *bmi, const void *bits)
CryptGetHashParam(hash, HP_HASHVAL, hash_buf, &hash_size, 0); CryptGetHashParam(hash, HP_HASHVAL, hash_buf, &hash_size, 0);
CryptDestroyHash(hash); CryptDestroyHash(hash);
buf = HeapAlloc(GetProcessHeap(), 0, hash_size * 2 + 1); buf = malloc(hash_size * 2 + 1);
for(i = 0; i < hash_size; i++) for(i = 0; i < hash_size; i++)
{ {
...@@ -1448,7 +1448,7 @@ static void compare_hash_broken_todo(HDC hdc, const BITMAPINFO *bmi, BYTE *bits, ...@@ -1448,7 +1448,7 @@ static void compare_hash_broken_todo(HDC hdc, const BITMAPINFO *bmi, BYTE *bits,
if(current_sha1[i] == NULL) if(current_sha1[i] == NULL)
{ {
ok(current_sha1[i] != NULL, "missing hash, got \"%s\",\n", hash); ok(current_sha1[i] != NULL, "missing hash, got \"%s\",\n", hash);
HeapFree(GetProcessHeap(), 0, hash); free(hash);
return; return;
} }
} }
...@@ -1464,7 +1464,7 @@ static void compare_hash_broken_todo(HDC hdc, const BITMAPINFO *bmi, BYTE *bits, ...@@ -1464,7 +1464,7 @@ static void compare_hash_broken_todo(HDC hdc, const BITMAPINFO *bmi, BYTE *bits,
current_sha1 += num_broken + 1; current_sha1 += num_broken + 1;
HeapFree(GetProcessHeap(), 0, hash); free( hash );
compare_bounds( hdc, info ); compare_bounds( hdc, info );
} }
...@@ -3129,8 +3129,8 @@ static void draw_text_2( HDC hdc, const BITMAPINFO *bmi, BYTE *bits, BOOL aa ) ...@@ -3129,8 +3129,8 @@ static void draw_text_2( HDC hdc, const BITMAPINFO *bmi, BYTE *bits, BOOL aa )
SetBkColor( hdc, bk_color ); SetBkColor( hdc, bk_color );
HeapFree( GetProcessHeap(), 0, diy_hash ); free( diy_hash );
HeapFree( GetProcessHeap(), 0, eto_hash ); free( eto_hash );
font = SelectObject( hdc, font ); font = SelectObject( hdc, font );
DeleteObject( font ); DeleteObject( font );
......
...@@ -2239,9 +2239,9 @@ static BOOL match_emf_record(const ENHMETARECORD *emr1, const ENHMETARECORD *emr ...@@ -2239,9 +2239,9 @@ static BOOL match_emf_record(const ENHMETARECORD *emr1, const ENHMETARECORD *emr
{ {
EMREXTTEXTOUTW *eto1, *eto2; EMREXTTEXTOUTW *eto1, *eto2;
eto1 = HeapAlloc(GetProcessHeap(), 0, emr1->nSize); eto1 = malloc(emr1->nSize);
memcpy(eto1, emr1, emr1->nSize); memcpy(eto1, emr1, emr1->nSize);
eto2 = HeapAlloc(GetProcessHeap(), 0, emr2->nSize); eto2 = malloc(emr2->nSize);
memcpy(eto2, emr2, emr2->nSize); memcpy(eto2, emr2, emr2->nSize);
/* different Windows versions setup DC scaling differently */ /* different Windows versions setup DC scaling differently */
...@@ -2254,8 +2254,8 @@ static BOOL match_emf_record(const ENHMETARECORD *emr1, const ENHMETARECORD *emr ...@@ -2254,8 +2254,8 @@ static BOOL match_emf_record(const ENHMETARECORD *emr1, const ENHMETARECORD *emr
dump_EMREXTTEXTOUT(eto1); dump_EMREXTTEXTOUT(eto1);
dump_EMREXTTEXTOUT(eto2); dump_EMREXTTEXTOUT(eto2);
} }
HeapFree(GetProcessHeap(), 0, eto1); free(eto1);
HeapFree(GetProcessHeap(), 0, eto2); free(eto2);
} }
else if (emr1->iType == EMR_EXTSELECTCLIPRGN && !lstrcmpA(desc, "emf_clipping")) else if (emr1->iType == EMR_EXTSELECTCLIPRGN && !lstrcmpA(desc, "emf_clipping"))
{ {
...@@ -4126,7 +4126,7 @@ static void test_mf_PatternBrush(void) ...@@ -4126,7 +4126,7 @@ static void test_mf_PatternBrush(void)
BOOL ret; BOOL ret;
INT type; INT type;
orig_lb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LOGBRUSH)); orig_lb = calloc(1, sizeof(LOGBRUSH));
orig_lb->lbStyle = BS_PATTERN; orig_lb->lbStyle = BS_PATTERN;
orig_lb->lbColor = RGB(0, 0, 0); orig_lb->lbColor = RGB(0, 0, 0);
...@@ -4180,7 +4180,7 @@ static void test_mf_PatternBrush(void) ...@@ -4180,7 +4180,7 @@ static void test_mf_PatternBrush(void)
ret = DeleteObject((HBITMAP)orig_lb->lbHatch); ret = DeleteObject((HBITMAP)orig_lb->lbHatch);
ok( ret, "DeleteObject(HBITMAP) error %ld\n", ok( ret, "DeleteObject(HBITMAP) error %ld\n",
GetLastError()); GetLastError());
HeapFree (GetProcessHeap(), 0, orig_lb); free(orig_lb);
} }
static int CALLBACK pattern_brush_emf_enum_proc(HDC hdc, HANDLETABLE *htable, static int CALLBACK pattern_brush_emf_enum_proc(HDC hdc, HANDLETABLE *htable,
...@@ -4227,7 +4227,7 @@ static void test_emf_pattern_brush(void) ...@@ -4227,7 +4227,7 @@ static void test_emf_pattern_brush(void)
unsigned int i; unsigned int i;
BOOL ret; BOOL ret;
orig_lb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LOGBRUSH)); orig_lb = calloc(1, sizeof(LOGBRUSH));
orig_lb->lbStyle = BS_PATTERN; orig_lb->lbStyle = BS_PATTERN;
orig_lb->lbColor = RGB(0, 0, 0); orig_lb->lbColor = RGB(0, 0, 0);
...@@ -4275,7 +4275,7 @@ static void test_emf_pattern_brush(void) ...@@ -4275,7 +4275,7 @@ static void test_emf_pattern_brush(void)
ok(ret, "DeleteObject failed\n"); ok(ret, "DeleteObject failed\n");
ret = DeleteObject((HBITMAP)orig_lb->lbHatch); ret = DeleteObject((HBITMAP)orig_lb->lbHatch);
ok(ret, "DeleteObject failed\n"); ok(ret, "DeleteObject failed\n");
HeapFree(GetProcessHeap(), 0, orig_lb); free(orig_lb);
ret = EnumEnhMetaFile(NULL, emf, pattern_brush_emf_enum_proc, NULL, NULL); ret = EnumEnhMetaFile(NULL, emf, pattern_brush_emf_enum_proc, NULL, NULL);
ok(ret, "EnumEnhMetaFile error %ld\n", GetLastError()); ok(ret, "EnumEnhMetaFile error %ld\n", GetLastError());
...@@ -8703,11 +8703,11 @@ static HENHMETAFILE create_converted_emf(const METAFILEPICT *mfp) ...@@ -8703,11 +8703,11 @@ static HENHMETAFILE create_converted_emf(const METAFILEPICT *mfp)
size = GetMetaFileBitsEx(hmf, 0, NULL); size = GetMetaFileBitsEx(hmf, 0, NULL);
ok(size, "GetMetaFileBitsEx failed with error %ld\n", GetLastError()); ok(size, "GetMetaFileBitsEx failed with error %ld\n", GetLastError());
pBits = HeapAlloc(GetProcessHeap(), 0, size); pBits = malloc(size);
GetMetaFileBitsEx(hmf, size, pBits); GetMetaFileBitsEx(hmf, size, pBits);
DeleteMetaFile(hmf); DeleteMetaFile(hmf);
hemf = SetWinMetaFileBits(size, pBits, NULL, mfp); hemf = SetWinMetaFileBits(size, pBits, NULL, mfp);
HeapFree(GetProcessHeap(), 0, pBits); free(pBits);
return hemf; return hemf;
} }
...@@ -8887,8 +8887,8 @@ static void test_SetWinMetaFileBits(void) ...@@ -8887,8 +8887,8 @@ static void test_SetWinMetaFileBits(void)
return; return;
} }
buffer = HeapAlloc(GetProcessHeap(), 0, buffer_size); buffer = malloc(buffer_size);
ok(buffer != NULL, "HeapAlloc failed\n"); ok(buffer != NULL, "malloc failed\n");
if (!buffer) if (!buffer)
{ {
DeleteMetaFile(wmf); DeleteMetaFile(wmf);
...@@ -8900,7 +8900,7 @@ static void test_SetWinMetaFileBits(void) ...@@ -8900,7 +8900,7 @@ static void test_SetWinMetaFileBits(void)
DeleteMetaFile(wmf); DeleteMetaFile(wmf);
if (res != buffer_size) if (res != buffer_size)
{ {
HeapFree(GetProcessHeap(), 0, buffer); free(buffer);
return; return;
} }
...@@ -8996,7 +8996,7 @@ static void test_SetWinMetaFileBits(void) ...@@ -8996,7 +8996,7 @@ static void test_SetWinMetaFileBits(void)
"SetWinMetaFileBits: xExt and yExt must be ignored for mapping modes other than MM_ANISOTROPIC and MM_ISOTROPIC\n"); "SetWinMetaFileBits: xExt and yExt must be ignored for mapping modes other than MM_ANISOTROPIC and MM_ISOTROPIC\n");
} }
HeapFree(GetProcessHeap(), 0, buffer); free(buffer);
} }
static BOOL near_match(int x, int y) static BOOL near_match(int x, int y)
...@@ -9049,7 +9049,7 @@ static void getwinmetafilebits(UINT mode, int scale, RECT *rc) ...@@ -9049,7 +9049,7 @@ static void getwinmetafilebits(UINT mode, int scale, RECT *rc)
ok(emf != NULL, "emf is NULL\n"); ok(emf != NULL, "emf is NULL\n");
emf_size = GetEnhMetaFileBits(emf, 0, NULL); emf_size = GetEnhMetaFileBits(emf, 0, NULL);
enh_header = HeapAlloc(GetProcessHeap(), 0, emf_size); enh_header = malloc(emf_size);
emf_size = GetEnhMetaFileBits(emf, emf_size, (BYTE*)enh_header); emf_size = GetEnhMetaFileBits(emf, emf_size, (BYTE*)enh_header);
DeleteEnhMetaFile(emf); DeleteEnhMetaFile(emf);
/* multiply szlDevice.cx by scale, when scale != 1 the recording and playback dcs /* multiply szlDevice.cx by scale, when scale != 1 the recording and playback dcs
...@@ -9064,7 +9064,7 @@ static void getwinmetafilebits(UINT mode, int scale, RECT *rc) ...@@ -9064,7 +9064,7 @@ static void getwinmetafilebits(UINT mode, int scale, RECT *rc)
broken(size == 0), /* some versions of winxp fail for some reason */ broken(size == 0), /* some versions of winxp fail for some reason */
"GetWinMetaFileBits returns 0\n"); "GetWinMetaFileBits returns 0\n");
if(!size) goto end; if(!size) goto end;
mh = HeapAlloc(GetProcessHeap(), 0, size); mh = malloc(size);
GetWinMetaFileBits(emf, size, (BYTE*)mh, mode, display_dc); GetWinMetaFileBits(emf, size, (BYTE*)mh, mode, display_dc);
for(i = 0; i < size / 2; i++) check += ((WORD*)mh)[i]; for(i = 0; i < size / 2; i++) check += ((WORD*)mh)[i];
...@@ -9172,16 +9172,16 @@ static void getwinmetafilebits(UINT mode, int scale, RECT *rc) ...@@ -9172,16 +9172,16 @@ static void getwinmetafilebits(UINT mode, int scale, RECT *rc)
emf2 = SetWinMetaFileBits( size, (BYTE*)mh, NULL, &mfp ); emf2 = SetWinMetaFileBits( size, (BYTE*)mh, NULL, &mfp );
ok( !!emf2, "got NULL\n" ); ok( !!emf2, "got NULL\n" );
emf2_size = GetEnhMetaFileBits( emf2, 0, NULL ); emf2_size = GetEnhMetaFileBits( emf2, 0, NULL );
enh2_header = HeapAlloc( GetProcessHeap(), 0, emf2_size ); enh2_header = malloc( emf2_size );
emf2_size = GetEnhMetaFileBits( emf2, emf2_size, (BYTE*)enh2_header ); emf2_size = GetEnhMetaFileBits( emf2, emf2_size, (BYTE*)enh2_header );
ok( emf_size == emf2_size, "%d %d\n", emf_size, emf2_size ); ok( emf_size == emf2_size, "%d %d\n", emf_size, emf2_size );
ok( !memcmp( enh_header, enh2_header, emf_size ), "mismatch\n" ); ok( !memcmp( enh_header, enh2_header, emf_size ), "mismatch\n" );
HeapFree( GetProcessHeap(), 0, enh2_header ); free( enh2_header );
DeleteEnhMetaFile( emf2 ); DeleteEnhMetaFile( emf2 );
end: end:
HeapFree(GetProcessHeap(), 0, mh); free(mh);
HeapFree(GetProcessHeap(), 0, enh_header); free(enh_header);
DeleteEnhMetaFile(emf); DeleteEnhMetaFile(emf);
ReleaseDC(NULL, display_dc); ReleaseDC(NULL, display_dc);
......
...@@ -413,9 +413,9 @@ static void ok_path(HDC hdc, const char *path_name, const path_test_t *expected, ...@@ -413,9 +413,9 @@ static void ok_path(HDC hdc, const char *path_name, const path_test_t *expected,
ok(size > 0, "GetPath returned size %d, last error %ld\n", size, GetLastError()); ok(size > 0, "GetPath returned size %d, last error %ld\n", size, GetLastError());
if (size <= 0) return; if (size <= 0) return;
pnt = HeapAlloc(GetProcessHeap(), 0, size*sizeof(POINT)); pnt = malloc(size * sizeof(POINT));
assert(pnt != 0); assert(pnt != 0);
types = HeapAlloc(GetProcessHeap(), 0, size*sizeof(BYTE)); types = malloc(size);
assert(types != 0); assert(types != 0);
size = GetPath(hdc, pnt, types, size); size = GetPath(hdc, pnt, types, size);
assert(size > 0); assert(size > 0);
...@@ -448,8 +448,8 @@ static void ok_path(HDC hdc, const char *path_name, const path_test_t *expected, ...@@ -448,8 +448,8 @@ static void ok_path(HDC hdc, const char *path_name, const path_test_t *expected,
printf("};\n" ); printf("};\n" );
} }
HeapFree(GetProcessHeap(), 0, types); free(types);
HeapFree(GetProcessHeap(), 0, pnt); free(pnt);
} }
static const path_test_t arcto_path[] = static const path_test_t arcto_path[] =
......
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