Replace SELECTOR_AllocBlock and SELECTOR_FreeBlock with standard Win16

selector calls.
This commit is contained in:
Andreas Mohr 2002-05-08 00:20:40 +00:00 committed by Alexandre Julliard
parent 5de5a44378
commit 757e7cb40d
3 changed files with 22 additions and 5 deletions

View File

@ -161,15 +161,15 @@ static void SELECTOR_SetEntries( WORD sel, const void *base, DWORD size, unsigne
WORD i, count;
wine_ldt_set_base( &entry, base );
wine_ldt_set_limit( &entry, size - 1 );
wine_ldt_set_flags( &entry, flags );
/* Make sure base and limit are not 0 together if the size is not 0 */
if (!base && size == 1) wine_ldt_set_limit( &entry, 1 );
wine_ldt_set_limit( &entry, (!base && size == 1) ? 1 : size - 1 );
wine_ldt_set_flags( &entry, flags );
count = (size + 0xffff) / 0x10000;
for (i = 0; i < count; i++)
{
wine_ldt_set_entry( sel + (i << __AHSHIFT), &entry );
wine_ldt_set_base( &entry, wine_ldt_get_base(&entry) + 0x10000 );
/* yep, Windows sets limit like that, not 64K sel units */
wine_ldt_set_limit( &entry, wine_ldt_get_limit(&entry) - 0x10000 );
}
}

View File

@ -443,7 +443,14 @@ BOOL BITMAP_DeleteObject( HBITMAP16 hbitmap, BITMAPOBJ * bmp )
}
HeapFree(GetProcessHeap(), 0, dib);
bmp->dib = NULL;
if (bmp->segptr_bits) SELECTOR_FreeBlock( SELECTOROF(bmp->segptr_bits) );
if (bmp->segptr_bits)
{ /* free its selector array */
WORD sel = SELECTOROF(bmp->segptr_bits);
WORD count = (GetSelectorLimit16(sel) / 0x10000) + 1;
int i;
for (i = 0; i < count; i++) FreeSelector16(sel + (i << __AHSHIFT));
}
}
return GDI_FreeObject( hbitmap, bmp );
}

View File

@ -895,7 +895,17 @@ HBITMAP16 WINAPI CreateDIBSection16 (HDC16 hdc, BITMAPINFO *bmi, UINT16 usage,
INT size = (bi->biSizeImage && bi->biCompression != BI_RGB) ?
bi->biSizeImage : width_bytes * height;
WORD sel = SELECTOR_AllocBlock( bits32, size, WINE_LDT_FLAGS_DATA );
/* calculate number of sel's needed for size with 64K steps */
WORD count = (size + 0xffff) / 0x10000;
WORD sel = AllocSelectorArray16(count);
int i;
for (i = 0; i < count; i++)
{
SetSelectorBase(sel + (i << __AHSHIFT), (DWORD)bits32 + i * 0x10000);
SetSelectorLimit16(sel + (i << __AHSHIFT), size - 1); /* yep, limit is correct */
size -= 0x10000;
}
bmp->segptr_bits = MAKESEGPTR( sel, 0 );
if (bits16) *bits16 = bmp->segptr_bits;
}