So, I have to create some nogc code. Basically all it uses is idup to create a string that is passed as a return value. It seems this is necessary or the string will be reused and corrupted.

idup uses the gc, I am currently just malloc'ing the string and allowing for the memory leak. This is somewhat acceptable given that this code should rarely be called and generally only at startup. It will generally waste only a few KB of memory.

Regardless, is there a better way to do this that avoids the gc and doesn't potentially leak considerably? Currently the only option is to notify the user through comments on the function that it leaks and should carefully be used.

Ultimately a struct is built which includes these strings(which is partly the corruption issue without idup).

How does phobos deal with this type of stuff? Does it force the user to allocate the memory so they are at least aware that they have to control it?

Reply via email to