/* Allocate a single block NET_BUF. Upon allocation, all the free space is in the tail room. */
NET_BUF* EFIAPI NetbufAlloc(IN UINT32 Len)
/* Allocate a single block NET_BUF. Upon allocation, all the free space is in the tail room. */
NET_BUF* EFIAPI NetbufAlloc(IN UINT32 Len)
{
  NET_BUF     *Nbuf;
  NET_VECTOR  *Vector;
  UINT8       *Bulk;
  ASSERT (Len > 0);
  Nbuf = NetbufAllocStruct (1, 1);
  if (Nbuf == NULL) {
    return NULL;
  }
  Bulk = AllocatePool (Len);
  if (Bulk == NULL) {
    goto FreeNBuf;
  }
  Vector      = Nbuf->Vector;
  Vector->Len = Len;
  Vector->Block[0].Bulk = Bulk;
  Vector->Block[0].Len  = Len;
  Nbuf->BlockOp[0].BlockHead = Bulk;
  Nbuf->BlockOp[0].BlockTail = Bulk + Len;
  Nbuf->BlockOp[0].Head = Bulk;
  Nbuf->BlockOp[0].Tail = Bulk;
  Nbuf->BlockOp[0].Size = 0;
  return Nbuf;
FreeNBuf:
  FreePool (Nbuf);
  return NULL;
}