/* nodestuff.c * Authors: Pete Broadwell * Josh Vickery * this file contains the procedure for allocating memory for a new node. */ #include "ll_defs.h" /* create a node. This procedure takes the node's contents (a string) as an argument. It returns a pointer to the complete node structure. */ node *create_n(char *data) { node *new_node; /* allocate memory */ new_node=(node *) malloc(sizeof(node)); if (new_node == NULL) { printf("Can't allocate memory for new node!\n"); exit(1); } /* set the fields on the new node */ strcpy(new_node->contents, data); new_node->previous=NULL; new_node->next=NULL; return(new_node); }