/* The use of a stream makes this function safer than the version without stream. */
UINT32 EFIAPI AmlRdStreamGetRdSize(IN CONST AML_STREAM *FStream)
/* The use of a stream makes this function safer than the version without stream. */
UINT32 EFIAPI AmlRdStreamGetRdSize(IN CONST AML_STREAM *FStream)
{
  CONST AML_RD_HEADER  *CurrRdElement;
  if (!IS_STREAM (FStream)        ||
      IS_END_OF_STREAM (FStream)  ||
      !IS_STREAM_FORWARD (FStream))
  {
    ASSERT (0);
    return 0;
  }
  CurrRdElement = (CONST AML_RD_HEADER *)AmlStreamGetCurrPos (FStream);
  if (CurrRdElement == NULL) {
    ASSERT (0);
    return 0;
  }
  if (AML_RD_IS_LARGE (CurrRdElement) &&
      (AmlStreamGetFreeSpace (FStream) <
       sizeof (ACPI_LARGE_RESOURCE_HEADER)))
  {
    return 0;
  }
  return AmlRdGetSize (CurrRdElement);
}