As in the C world we known MAX_PATH, might it not be better to change the
semantics of the call so that it returns the path?

I agree that the function itself should handle the problem of allocating
sufficient buffer, freeing the buffer and simply return the path.

On a related note:  if a C function mallocs some memory and returns a
pointer
to that memory, does p/invoke free the memory once marshalling is
complete?

No. There is simply no way to automatically determine whether it should be
freed and there is even less chance to determine how (using what function)
it should be freed.

If you want to do so you have to use an IntPtr that you can free manually.
Note that you can alternatively use a custom marshaler but you have to do
the same with a more complex and probably more proper design.

Kornél

_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to