- There is currently no need to lock more than three objects at a time, this permits code simplification/speed
  - Keep the handles order in GDIOBJ_LockMultipleObjs
Still unused...

svn path=/branches/reactos-yarotows/; revision=46899
This commit is contained in:
Jérôme Gardou 2010-04-16 16:55:52 +00:00
parent 6a8d2ef675
commit 4ec4675b9e

View file

@ -1625,37 +1625,39 @@ GDI_MapHandleTable(PSECTION_OBJECT SectionObject, PEPROCESS Process)
return MappedView; return MappedView;
} }
/* Locks multiple objects at a time */ /* Locks up to 3 objects at a time */
VOID VOID
INTERNAL_CALL INTERNAL_CALL
GDIOBJ_LockMultipleObjs(ULONG ulCount, GDIOBJ_LockMultipleObjs(ULONG ulCount,
IN HGDIOBJ* ahObj, IN HGDIOBJ* ahObj,
OUT PGDIOBJ* apObj) OUT PGDIOBJ* apObj)
{ {
UINT i; UINT iFirst = 0, iSecond = 0, iThird = 0;
HGDIOBJ hTmp ; UINT i ;
BOOL unsorted = TRUE;
/* We bubble-sort them */ /* First is greatest */
while(unsorted) for(i=1; i<ulCount; i++)
{ {
unsorted = FALSE ; if((ULONG_PTR)ahObj[i] >= (ULONG_PTR)ahObj[iFirst])
for(i=0; i<ulCount - 1; i++)
{ {
/* The greatest the first */ iSecond = iFirst ;
if((ULONG_PTR)ahObj[i] < (ULONG_PTR)ahObj[i+1]) iFirst = i;
{ continue ;
hTmp = ahObj[i];
ahObj[i]=ahObj[i+1];
ahObj[i+1] = hTmp;
unsorted = TRUE ;
}
} }
if((ULONG_PTR)ahObj[i] >= (ULONG_PTR)ahObj[iSecond])
{
iSecond = i;
continue;
}
iThird = i;
} }
/* Then we lock them */
for(i=0; i<ulCount; i++) /* We consider that at least two handles were passed */
{ apObj[iFirst] = GDIOBJ_LockObj(ahObj[iFirst], GDI_OBJECT_TYPE_DONTCARE);
apObj[i]=GDIOBJ_LockObj(ahObj[i], GDI_OBJECT_TYPE_DONTCARE); apObj[iSecond] = GDIOBJ_LockObj(ahObj[iSecond], GDI_OBJECT_TYPE_DONTCARE);
} if(ulCount == 3)
apObj[iThird] = GDIOBJ_LockObj(ahObj[iThird], GDI_OBJECT_TYPE_DONTCARE);
} }