mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 04:23:32 +00:00
[GDI32]: Don't destroy the heap when calling GetSystemPaletteEntries. Note to whoever wrote "//make this work": (&array[x]) is defintely not equal to (&array + x). This is why we don't use pointers-to-arrays, among other reasons.
[GDI32]: Reformat GetSystemPaletteEntries away from grotesque 5-space identation (who does that?). [GDI32]: Optimize GetSystemPaletteEntries by not zeroing over fields that get overwritten anyway. [GDI32]: Simplify loop control, remove not-needed local variable in GetSystemPaletteEntries. svn path=/trunk/; revision=48716
This commit is contained in:
parent
65fc01dc92
commit
b96cb710f4
1 changed files with 26 additions and 24 deletions
|
@ -86,34 +86,36 @@ GetSystemPaletteEntries(HDC hDC,
|
||||||
UINT cEntries,
|
UINT cEntries,
|
||||||
LPPALETTEENTRY ppe)
|
LPPALETTEENTRY ppe)
|
||||||
{
|
{
|
||||||
PALETTEENTRY ippe[256];
|
PALETTEENTRY ippe[256];
|
||||||
// Make this work!
|
|
||||||
if ((INT)cEntries < 0 ) return 0;
|
|
||||||
|
|
||||||
if ( GetDeviceCaps(hDC, RASTERCAPS) & RC_PALETTE )
|
if ((INT)cEntries >= 0)
|
||||||
return NtGdiDoPalette(hDC, iStartIndex, cEntries, ppe, GdiPalGetSystemEntries, FALSE);
|
{
|
||||||
else
|
if (GetDeviceCaps(hDC, RASTERCAPS) & RC_PALETTE)
|
||||||
{
|
|
||||||
if (ppe)
|
|
||||||
{
|
{
|
||||||
RtlZeroMemory( &ippe, sizeof(ippe) );
|
return NtGdiDoPalette(hDC,
|
||||||
RtlCopyMemory( &ippe, &sys_pal_template, 10 * sizeof(PALETTEENTRY) );
|
iStartIndex,
|
||||||
RtlCopyMemory( &ippe + 246 , &sys_pal_template + 10 , 10 * sizeof(PALETTEENTRY) );
|
cEntries,
|
||||||
|
ppe,
|
||||||
if (iStartIndex < 256)
|
GdiPalGetSystemEntries,
|
||||||
{
|
FALSE);
|
||||||
UINT Index = 256 - iStartIndex;
|
|
||||||
|
|
||||||
if ( Index > cEntries ) Index = cEntries;
|
|
||||||
|
|
||||||
RtlCopyMemory( ppe,
|
|
||||||
&ippe[iStartIndex],
|
|
||||||
Index*sizeof(PALETTEENTRY));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
else if (ppe)
|
||||||
|
{
|
||||||
|
RtlCopyMemory(ippe, sys_pal_template, 10 * sizeof(PALETTEENTRY));
|
||||||
|
RtlCopyMemory(&ippe[246], &sys_pal_template[10], 10 * sizeof(PALETTEENTRY));
|
||||||
|
RtlZeroMemory(&ippe[10], sizeof(ippe) - 20 * sizeof(PALETTEENTRY));
|
||||||
|
|
||||||
|
if (iStartIndex < 256)
|
||||||
|
{
|
||||||
|
RtlCopyMemory(ppe,
|
||||||
|
&ippe[iStartIndex],
|
||||||
|
min(256 - iStartIndex, cEntries) *
|
||||||
|
sizeof(PALETTEENTRY));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT
|
UINT
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue