/* Call Visitor function for each variable in variable storage. */
VOID BmForEachVariable(BM_VARIABLE_VISITOR Visitor, VOID *Context)
/* Call Visitor function for each variable in variable storage. */
VOID BmForEachVariable(BM_VARIABLE_VISITOR Visitor, VOID *Context)
{
  EFI_STATUS  Status;
  CHAR16      *Name;
  EFI_GUID    Guid;
  UINTN       NameSize;
  UINTN       NewNameSize;
  NameSize = sizeof (CHAR16);
  Name     = AllocateZeroPool (NameSize);
  ASSERT (Name != NULL);
  while (TRUE) {
    NewNameSize = NameSize;
    Status      = gRT->GetNextVariableName (&NewNameSize, Name, &Guid);
    if (Status == EFI_BUFFER_TOO_SMALL) {
      Name = ReallocatePool (NameSize, NewNameSize, Name);
      ASSERT (Name != NULL);
      Status   = gRT->GetNextVariableName (&NewNameSize, Name, &Guid);
      NameSize = NewNameSize;
    }
    if (Status == EFI_NOT_FOUND) {
      break;
    }
    ASSERT_EFI_ERROR (Status);
    Visitor (Name, &Guid, Context);
  }
  FreePool (Name);
}