/*static char *SCCSID = "@(#)retvoltb.c	6.4 92/01/31";*/
#define BSWAP1 BSWAP1
#include <os2def.h>
#include <bse.h>
#include <fsd.h>

#include "heap.h"
#include "chain.h"
#include "const.h"
#include "misc.h"
#include "buf.h"
#include "dir.h"
#include "volume.h"
#include "frame.h"
#include "pr_fsini.h"
#include "pr_HEAP.h"

/* put volume mounting functions in different code segment */

/*
 ***	RetVolTab - Return VolTab Space
 *
 *	RetVolTab is called to return the heap space allocated
 *	to the VOLTAB structure and it's descendant structures.
 *	RetVolTab assumes that the SBDIR tree consists of only
 *	the root SBDIR record, if any.  (Caller must delete any
 *	underlying SBDIR records.)  RetVolTab also doesn't address
 *	dirty buffers, directory lookasides, etc.
 *
 *	RetVolTab can be called by an unmount sequence, in which
 *	case all the dependent heap structures will be present, or
 *	it may be called during an aborted mount, in which case
 *	some of these guys may be absent.
 *
 *	ENTRY	 pvol - pointer to VOLTAB structure to be returned
 *
 *	Returns: NONE
 *
 */

void
RetVolTab (PVOLTAB pvol)	/* pointer to VOLTAB to return */
{
	/* BUGBUG: There are two HotFix pointers that need to be attended to. */

	if (pvol->apbndList[0] != NULL) {
	    UINT uiBand;

	    for( uiBand = 0; uiBand < pvol->cBands;
					    uiBand += C_BANDS_IN_BUFFER ) {
		FreeBandTabBuff( pvol->apbndList[uiBand] );
	    }
	}

	if (pvol->psbdRoot != NULL) {
	    RetHeap (pvol->psbdRoot->dh.pspName);
	    RetHeap (pvol->psbdRoot);
	}

	if (pvol->pHotFixNew != NULL)
	    RetHeap (pvol->pHotFixNew);

	if (pvol->pHotFixArray != NULL)
	    RetHeap (pvol->pHotFixArray);

	RetHeap (pvol);
}
