/**********************************************************************
 * ti library's routine for freeing a menu node
 *
 * $Author: brlewis $
 * $Source: /afs/net.mit.edu/dapps/project/techinfodev/src/libti/RCS/freenode.c,v $
 * $Header: /afs/net.mit.edu/dapps/project/techinfodev/src/libti/RCS/freenode.c,v 0.2 92/07/09 17:04:33 brlewis Exp Locker: brlewis $
 *
 * Copyright 1992 by the Massachusetts Institute of Technology.
 *
 * For copying and distribution information, please see the file
 * <mit-copyright.h>.
 **********************************************************************/

#include <mit-copyright.h>

#ifndef lint
static char rcsid_ti_freenode_c[] = "$Header: /afs/net.mit.edu/dapps/project/techinfodev/src/libti/RCS/freenode.c,v 0.2 92/07/09 17:04:33 brlewis Exp Locker: brlewis $";
#endif /* lint */

#include <ti/memory.h>
#include <ti/ti.h>

/* jms 7/24/92 -- windows-izing sort of completed, pending approval */

/**********************************************************************
 * ti_freenode(ti_node_H hnode)
 *
 * - frees memory allocated by ti_newnode()
 **********************************************************************/

TI_INLINE
void
ti_freenode(hnode)
     ti_node_H hnode;
{
  ti_node_LP lpnode;

  lpnode = TI_DEREFERENCE(hnode);
  Delete(lpnode->nd_hdata);
  TI_REMOVE_DEREFERENCE(hnode, lpnode);
  Delete(hnode);
  return;
}

/**********************************************************************
 * ti_freenodes(ti_node_HH hhnodes)
 *
 * - frees memory allocated by ti_rdmenu()
 **********************************************************************/

/* this is just yucky. handles to handles -- bleah! */

TI_INLINE
void
ti_freenodes(hhnodes)
     ti_node_HH hhnodes;
{
  ti_node_LPH hnodescan, hnodes;
  hnodescan = hnodes = (ti_node_LPH)TI_DEREFERENCE(hhnodes)

  for (; *hnodescan; hnodescan++) ti_freenode(*hnodescan);
  TI_REMOVE_DEREFERENCE(hhnodes, hnodes);
  Delete(hhnodes);
  return;
}
