In the future, I will avoid asking "why didnt that work?" style questions like I did in the later posts of this thread.
That is not the problem. The problem is, that you seem to be advice-resistant. So here is my last comment concerning this topic. Go with HeelXs solution. It's clean, effective and fast - maybe even faster than yours. Your solution is error prone and has at least one other memory leak you haven't noticed yet. Several other problems might arise from it.