/* The net buffer allocated has the BlockOpNum's NET_BLOCK_OP, and its associated NET_VECTOR has the BlockNum's NET_BLOCK. But all the NET_BLOCK_OP and NET_BLOCK remain un-initialized. */
NET_BUF* NetbufAllocStruct(IN UINT32 BlockNum, IN UINT32 BlockOpNum)
/* The net buffer allocated has the BlockOpNum's NET_BLOCK_OP, and its associated NET_VECTOR has the BlockNum's NET_BLOCK. But all the NET_BLOCK_OP and NET_BLOCK remain un-initialized. */
NET_BUF* NetbufAllocStruct(IN UINT32 BlockNum, IN UINT32 BlockOpNum)
{
  NET_BUF     *Nbuf;
  NET_VECTOR  *Vector;
  ASSERT (BlockOpNum >= 1);
  Nbuf = AllocateZeroPool (NET_BUF_SIZE (BlockOpNum));
  if (Nbuf == NULL) {
    return NULL;
  }
  Nbuf->Signature  = NET_BUF_SIGNATURE;
  Nbuf->RefCnt     = 1;
  Nbuf->BlockOpNum = BlockOpNum;
  InitializeListHead (&Nbuf->List);
  if (BlockNum != 0) {
    Vector = AllocateZeroPool (NET_VECTOR_SIZE (BlockNum));
    if (Vector == NULL) {
      goto FreeNbuf;
    }
    Vector->Signature = NET_VECTOR_SIGNATURE;
    Vector->RefCnt    = 1;
    Vector->BlockNum  = BlockNum;
    Nbuf->Vector      = Vector;
  }
  return Nbuf;
FreeNbuf:
  FreePool (Nbuf);
  return NULL;
}