diff --git a/reactos/subsys/win32k/eng/handle.c b/reactos/subsys/win32k/eng/handle.c index 3e6ad67a951..65716481df4 100644 --- a/reactos/subsys/win32k/eng/handle.c +++ b/reactos/subsys/win32k/eng/handle.c @@ -14,6 +14,7 @@ #define NDEBUG #include +static int LastHandle = MAX_GDI_HANDLES; ULONG CreateGDIHandle(ULONG InternalSize, ULONG UserSize) { @@ -31,11 +32,13 @@ ULONG CreateGDIHandle(ULONG InternalSize, ULONG UserSize) pObj->InternalSize = InternalSize; pObj->UserSize = UserSize; - for( i=1; i < MAX_GDI_HANDLES; i++ ){ + for( i = (MAX_GDI_HANDLES - 1 <= LastHandle ? 1 : LastHandle + 1); i != LastHandle; + i = (MAX_GDI_HANDLES - 1 <= i ? 1 : i + 1) ){ if( GDIHandles[ i ].pEngObj == NULL ){ pObj->hObj = i; GDIHandles[ i ].pEngObj = pObj; DPRINT("CreateGDIHandle: obj: %x, handle: %d, usersize: %d\n", pObj, i, UserSize ); + LastHandle = i; return i; } }