home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_09_11
/
9n11031a
< prev
next >
Wrap
Text File
|
1991-08-27
|
691b
|
31 lines
/* --------------------------------------------------------------
FUNCTION GET_FREE_NODE: The steps to get a node from the free node
list are:
A. If the free node list is empty, get memory for a new node and
return its address.
B. Else remove the first node from the free list and use that.
-------------------------------------------------------------- */
Node *get_free_node(void)
{
const Node *pnew_node;
/*A*/ if (pfree_node == NULL) {
pnew_node = malloc(sizeof(Node));
}
/*B*/ else {
pnew_node = pfree_node;
pfree_node = pfree_node->pfwd;
}
return pnew_node;
}
/* ----------------------------------------------------------- */