Identifier::~Identifier() { LineNumberList *root = getLineNumberList(); LineNumberList *tmp = root; while (root != NULL) { tmp = tmp->getNextLineNumber(); delete root; root = tmp; } }
Identifier::~Identifier() { //What code do I need here to free memory LineNumberList *root = getLineNumberList(); LineNumberList *tmp = root; while (root != NULL) { tmp = tmp->getNextLineNumber(); delete root; root = tmp; } }
void Identifier::addToLineNumberList(LineNumberList *listItem) { LineNumberList *tmp = getLineNumberList(); if (tmp == NULL) { list = listItem; } else { while (tmp->getNextLineNumber() != NULL) { tmp = tmp->getNextLineNumber(); } tmp->setNextLineNumber(listItem); } }
Token::~Token() { //What code do I need here to free memory LineNumberList *root = getLineNumberList(); LineNumberList *tmp = root; while (root != NULL) { tmp = tmp->getNextLineNumber(); delete root; root = tmp; } if (this->getType() == STRING_LIT) { free(this->literal.stringLiteral); } }