diff --git a/2.x/trunk/ProcessHacker/about.c b/2.x/trunk/ProcessHacker/about.c index 72e5b8747..2c4aec387 100644 --- a/2.x/trunk/ProcessHacker/about.c +++ b/2.x/trunk/ProcessHacker/about.c @@ -152,7 +152,6 @@ PPH_STRING PhGetDiagnosticsString( OBJECT_TYPE_COUNT(PhFullStringType); OBJECT_TYPE_COUNT(PhListType); OBJECT_TYPE_COUNT(PhPointerListType); - OBJECT_TYPE_COUNT(PhQueueType); OBJECT_TYPE_COUNT(PhHashtableType); OBJECT_TYPE_COUNT(PhFileStreamType); diff --git a/2.x/trunk/ProcessHacker/dbgcon.c b/2.x/trunk/ProcessHacker/dbgcon.c index 73870cb53..baad3b1b1 100644 --- a/2.x/trunk/ProcessHacker/dbgcon.c +++ b/2.x/trunk/ProcessHacker/dbgcon.c @@ -195,10 +195,6 @@ static VOID PhpPrintObjectInfo( { wprintf(L"\tCount: %u", ((PPH_POINTER_LIST)PhObjectHeaderToObject(ObjectHeader))->Count); } - else if (ObjectHeader->Type == PhQueueType) - { - wprintf(L"\tCount: %u", ((PPH_QUEUE)PhObjectHeaderToObject(ObjectHeader))->Count); - } else if (ObjectHeader->Type == PhHashtableType) { wprintf(L"\tCount: %u", ((PPH_HASHTABLE)PhObjectHeaderToObject(ObjectHeader))->Count); diff --git a/2.x/trunk/phlib/basesup.c b/2.x/trunk/phlib/basesup.c index dd43fc30b..580369922 100644 --- a/2.x/trunk/phlib/basesup.c +++ b/2.x/trunk/phlib/basesup.c @@ -109,7 +109,6 @@ PPH_OBJECT_TYPE PhAnsiStringType; PPH_OBJECT_TYPE PhFullStringType; PPH_OBJECT_TYPE PhListType; PPH_OBJECT_TYPE PhPointerListType; -PPH_OBJECT_TYPE PhQueueType; PPH_OBJECT_TYPE PhHashtableType; // Misc. @@ -196,14 +195,6 @@ BOOLEAN PhInitializeBase( ))) return FALSE; - if (!NT_SUCCESS(PhCreateObjectType( - &PhQueueType, - L"Queue", - 0, - PhpQueueDeleteProcedure - ))) - return FALSE; - parameters.FreeListSize = sizeof(PH_HASHTABLE); parameters.FreeListCount = 64; @@ -2212,19 +2203,21 @@ VOID PhInitializeStringBuilder( __in ULONG InitialCapacity ) { + // Make sure the initial capacity is even, as required for all string objects. + if (InitialCapacity & 1) + InitialCapacity++; + StringBuilder->AllocatedLength = InitialCapacity; // Allocate a PH_STRING for the string builder. - // We will dereference it and allocate a new one - // when we need to resize the string. + // We will dereference it and allocate a new one when we need to resize the string. StringBuilder->String = PhCreateStringEx( NULL, StringBuilder->AllocatedLength ); - // We will keep modifying the Length field of the - // string so: + // We will keep modifying the Length field of the string so: // 1. We know how much of the string is used, and // 2. The user can simply get a reference to the // string and use it as-is. @@ -3162,142 +3155,6 @@ VOID PhRemoveItemPointerList( PointerList->Count--; } -/** - * Creates a queue object. - * - * \param InitialCapacity The number of elements to - * allocate storage for initially. - */ -PPH_QUEUE PhCreateQueue( - __in ULONG InitialCapacity - ) -{ - PPH_QUEUE queue; - - if (!NT_SUCCESS(PhCreateObject( - &queue, - sizeof(PH_QUEUE), - 0, - PhQueueType - ))) - return NULL; - - // Initial capacity of 0 is not allowed. - if (InitialCapacity == 0) - InitialCapacity = 1; - - queue->Count = 0; - queue->AllocatedCount = InitialCapacity; - queue->Items = PhAllocate(queue->AllocatedCount * sizeof(PVOID)); - queue->Head = 0; - queue->Tail = 0; - - return queue; -} - -VOID NTAPI PhpQueueDeleteProcedure( - __in PVOID Object, - __in ULONG Flags - ) -{ - PPH_QUEUE queue = (PPH_QUEUE)Object; - - PhFree(queue->Items); -} - -/** - * Enqueues an item to a queue. - * - * \param Queue A queue object. - * \param Item The item to enqueue. - */ -VOID PhEnqueueItemQueue( - __inout PPH_QUEUE Queue, - __in PVOID Item - ) -{ - // See if we need to resize the queue. - if (Queue->Count == Queue->AllocatedCount) - { - ULONG oldAllocatedCount = Queue->AllocatedCount; - PVOID *oldItems = Queue->Items; - - Queue->AllocatedCount *= 2; - Queue->Items = PhAllocate(Queue->AllocatedCount * sizeof(PVOID)); - - // Copy the old items over if necessary. - if (Queue->Count > 0) - { - if (Queue->Head < Queue->Tail) - { - memcpy(Queue->Items, &oldItems[Queue->Head], Queue->Count * sizeof(PVOID)); - } - else - { - memcpy(Queue->Items, &oldItems[Queue->Head], (oldAllocatedCount - Queue->Head) * sizeof(PVOID)); - memcpy(&Queue->Items[oldAllocatedCount - Queue->Head], oldItems, Queue->Tail * sizeof(PVOID)); - } - } - - PhFree(oldItems); - Queue->Head = 0; - Queue->Tail = Queue->Count; - } - - Queue->Items[Queue->Tail] = Item; - Queue->Tail = (Queue->Tail + 1) % Queue->AllocatedCount; - Queue->Count++; -} - -/** - * Dequeues an item from a queue. - * - * \param Queue A queue object. - * \param Item A variable which receives the - * dequeued item. - * - * \return TRUE if an item was dequeued, - * FALSE if the queue was empty. - */ -BOOLEAN PhDequeueItemQueue( - __inout PPH_QUEUE Queue, - __out PVOID *Item - ) -{ - if (Queue->Count == 0) - return FALSE; - - *Item = Queue->Items[Queue->Head]; - Queue->Head = (Queue->Head + 1) % Queue->AllocatedCount; - Queue->Count--; - - return TRUE; -} - -/** - * Retrieves an item from the front of a queue - * without removing it. - * - * \param Queue A queue object. - * \param Item A variable which receives the - * item. - * - * \return TRUE if an item was retrieved, - * FALSE if the queue was empty. - */ -BOOLEAN PhPeekItemQueue( - __in PPH_QUEUE Queue, - __out PVOID *Item - ) -{ - if (Queue->Count == 0) - return FALSE; - - *Item = Queue->Items[Queue->Head]; - - return TRUE; -} - FORCEINLINE ULONG PhpValidateHash( __in ULONG Hash ) diff --git a/2.x/trunk/phlib/include/phbase.h b/2.x/trunk/phlib/include/phbase.h index 8aa1c6c58..feeacc6ad 100644 --- a/2.x/trunk/phlib/include/phbase.h +++ b/2.x/trunk/phlib/include/phbase.h @@ -2311,62 +2311,6 @@ FORCEINLINE BOOLEAN PhEnumPointerList( return FALSE; } -// queue - -#ifndef _PH_BASESUP_PRIVATE -extern PPH_OBJECT_TYPE PhQueueType; -#endif - -/** - * A queue structure. - * Storage is automatically allocated for new - * elements. - */ -typedef struct _PH_QUEUE -{ - /** The number of items in the queue. */ - ULONG Count; - /** The number of items for which storage is allocated. */ - ULONG AllocatedCount; - /** The array of queue items. */ - PVOID *Items; - /** The index of the first slot in the queue. */ - ULONG Head; - /** The index of the last available slot in the queue. */ - ULONG Tail; -} PH_QUEUE, *PPH_QUEUE; - -PHLIBAPI -PPH_QUEUE -NTAPI -PhCreateQueue( - __in ULONG InitialCapacity - ); - -PHLIBAPI -VOID -NTAPI -PhEnqueueItemQueue( - __inout PPH_QUEUE Queue, - __in PVOID Item - ); - -PHLIBAPI -BOOLEAN -NTAPI -PhDequeueItemQueue( - __inout PPH_QUEUE Queue, - __out PVOID *Item - ); - -PHLIBAPI -BOOLEAN -NTAPI -PhPeekItemQueue( - __in PPH_QUEUE Queue, - __out PVOID *Item - ); - // hash typedef struct _PH_HASH_ENTRY