One more thing: shouldn't karnavor's MyFunction(...) as it is defined in the first post also cause a memory leak? Once the function exits, the newly created data is lost; since, although the data is passed by reference, the pointer itself is passed by value, right?