- Resolve two GDI handle leaks

- Faster GDI handle allocation strategy

svn path=/trunk/; revision=7952
This commit is contained in:
Filip Navara 2004-02-01 08:07:07 +00:00
parent a4b82ffa87
commit 981a893bbd
2 changed files with 31 additions and 12 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* *
* $Id: painting.c,v 1.64 2004/01/21 17:23:55 navaraf Exp $ * $Id: painting.c,v 1.65 2004/02/01 08:07:07 navaraf Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -147,6 +147,8 @@ IntGetNCUpdateRegion(PWINDOW_OBJECT Window)
Window->UpdateRegion = NULL; Window->UpdateRegion = NULL;
} }
NtGdiDeleteObject(WindowRgn);
return NonclientRgn; return NonclientRgn;
} }
@ -554,7 +556,7 @@ IntRedrawWindow(PWINDOW_OBJECT Window, const RECT* UpdateRect, HRGN UpdateRgn,
* Cleanup ;-) * Cleanup ;-)
*/ */
if (NULL != hRgn) if (hRgn != NULL)
{ {
NtGdiDeleteObject(hRgn); NtGdiDeleteObject(hRgn);
} }
@ -931,6 +933,7 @@ NtUserGetUpdateRect(HWND hWnd, LPRECT lpRect, BOOL fErase)
NtUserGetUpdateRgn(hWnd, hRgn, fErase); NtUserGetUpdateRgn(hWnd, hRgn, fErase);
NtGdiGetRgnBox(hRgn, lpRect); NtGdiGetRgnBox(hRgn, lpRect);
NtGdiDeleteObject(hRgn);
return lpRect->left < lpRect->right && lpRect->top < lpRect->bottom; return lpRect->left < lpRect->right && lpRect->top < lpRect->bottom;
} }

View file

@ -19,7 +19,7 @@
/* /*
* GDIOBJ.C - GDI object manipulation routines * GDIOBJ.C - GDI object manipulation routines
* *
* $Id: gdiobj.c,v 1.57 2004/01/30 13:11:52 rcampbell Exp $ * $Id: gdiobj.c,v 1.58 2004/02/01 08:07:07 navaraf Exp $
* *
*/ */
@ -84,6 +84,7 @@ typedef struct _GDI_HANDLE_TABLE
{ {
WORD wTableSize; WORD wTableSize;
PGDIOBJHDR Handles[1]; PGDIOBJHDR Handles[1];
WORD AllocationHint;
} GDI_HANDLE_TABLE, *PGDI_HANDLE_TABLE; } GDI_HANDLE_TABLE, *PGDI_HANDLE_TABLE;
/* GDI stock objects */ /* GDI stock objects */
@ -176,6 +177,7 @@ GDIOBJ_iAllocHandleTable (WORD Size)
0, 0,
sizeof(GDI_HANDLE_TABLE) + sizeof(PGDIOBJ) * Size); sizeof(GDI_HANDLE_TABLE) + sizeof(PGDIOBJ) * Size);
handleTable->wTableSize = Size; handleTable->wTableSize = Size;
handleTable->AllocationHint = 1;
ExReleaseFastMutexUnsafe (&HandleTableMutex); ExReleaseFastMutexUnsafe (&HandleTableMutex);
KfLowerIrql(PrevIrql); KfLowerIrql(PrevIrql);
@ -204,17 +206,31 @@ GDIOBJ_iGetObjectForIndex(WORD TableIndex)
static WORD FASTCALL static WORD FASTCALL
GDIOBJ_iGetNextOpenHandleIndex (void) GDIOBJ_iGetNextOpenHandleIndex (void)
{ {
WORD tableIndex; WORD tableIndex;
for (tableIndex = 1; tableIndex < HandleTable->wTableSize; tableIndex++) for (tableIndex = HandleTable->AllocationHint;
{ tableIndex < HandleTable->wTableSize;
if (NULL == HandleTable->Handles[tableIndex]) tableIndex++)
{ {
break; if (HandleTable->Handles[tableIndex] == NULL)
} {
} HandleTable->AllocationHint = tableIndex + 1;
return tableIndex;
}
}
return (tableIndex < HandleTable->wTableSize) ? tableIndex : 0; for (tableIndex = 1;
tableIndex < HandleTable->AllocationHint;
tableIndex++)
{
if (HandleTable->Handles[tableIndex] == NULL)
{
HandleTable->AllocationHint = tableIndex + 1;
return tableIndex;
}
}
return 0;
} }
/*! /*!