void ZapAcl (struct Acl *acl) { if (!acl) return; ZapList(acl->pluslist); ZapList(acl->minuslist); free(acl); }
/**************************** BuildList ***************************** DESCRIPTION Builds a singly linked list with a dummy head node. The characters in the list are in the same order in which the user enters them, i.e. new characters are added to the tail end of the list. Input terminates when the enter key is pressed. PARAMETERS IN, List A pointer to a singly linked list with a dummy head node. It is imperative that List be initialized before calling this routine. NOTE Before building the new list, ZapList is called. This ensures that a memory leak does not develop. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ void BuildList (NodePtr List) { ZapList(List); //makes sure List is empty char NewChar; cin.get(NewChar); while (NewChar != '\n') { List -> Link = new (nothrow) Node; //create a new Node if (List -> Link == NULL) //make sure Node was created return; List = List -> Link; //List points to the new Node List -> Ch = NewChar; //fill Ch part of new Node List -> Link = NULL; //make sure the List ends with NULL cin.get(NewChar); } }