Your code is leaking memory -- you have calls to malloc but no corresponding calls to free. You should free the memory once you no longer need the temporary expansion.


Anyway - your question -- ...