
It's a bit late in the thread, but I just wanted to mention that if your executable and DLL both link to the *shared* version of msvcrt (and the same shared version, e.g. mult-threaded debug, single-threaded release, etc) and not the static version of msvcrt, then you should have no problems deleting across dll boundaries. The problem occurs when two different modules have two different copies of the crt and one of those module tries to delete memory allocated by the other module. The reason you often see windows api calls providing functions like NetApiFreeBuffer, etc is because they are implemented in a single dll (usually kernel32.dll) and there is only 1 copy of that dll on your system, that must work regardless of which version of the crt you link against.