yes, but it works for Me.
That sounds like a fundamental lack of knowledge in regards to memory management. Which is bad the second you start playing with dynamically allocated memory.
sid Do you know a better way?
Yes. But you should google "memory leak" and use the manual to find out why it is a memory leak, what's so bad about it and how it's fixed.