/* Add the length of the specified type to List. */
VOID AddMemoryLength(LIST_ENTRY *List, UINT32 Type, UINT64 NumberOfPages)
/* Add the length of the specified type to List. */
VOID AddMemoryLength(LIST_ENTRY *List, UINT32 Type, UINT64 NumberOfPages)
{
  MEMORY_LENGTH_ENTRY  *Entry;
  MEMORY_LENGTH_ENTRY  *NewEntry;
  LIST_ENTRY           *Link;
  Entry = NULL;
  for (Link = GetFirstNode (List); !IsNull (List, Link); Link = GetNextNode (List, Link)) {
    Entry = BASE_CR (Link, MEMORY_LENGTH_ENTRY, Link);
    if (Entry->Type >= Type) {
      break;
    }
  }
  if ((Entry != NULL) && (Entry->Type == Type)) {
    NewEntry = Entry;
  } else {
    NewEntry = AllocatePool (sizeof (*NewEntry));
    if (NewEntry == NULL) {
      return;
    }
    NewEntry->Type          = Type;
    NewEntry->NumberOfPages = 0;
    InsertTailList (Link, &NewEntry->Link);
  }
  NewEntry->NumberOfPages += NumberOfPages;
}