...and now I have a memory leak. I know where it's coming but not how to fix it.
The tokenizePrgm() function (which is the core of my tokenizer code- it's essentially a main function called by the real main function in another file) creates a pointer to an array of NUM_TOKEN tokenInfo objects.
This array is passed to an initTokens() procedure, which builds tokenInfo objects based on data stored in three arrays (this will change, obviously, when I implement the token file). I dynamically allocate memory to the names of each of those tokens.
The tokens array is then passed to all functions that need to use it, and at the end, in tokenizePrgm() I free up the tokens array.
Unfortunately, I haven't freed up the memory I allocated to the tokenInfo.name part of each token. And if I try to do it by looping over each token and calling:
free(tokens[i].name);
I get an address error.
Is there any way I can free this memory, or is the only solution not to use dynamic memory allocation here?