gtkd-developers / gir-to-d

Create D bindings from GObject introspection files
GNU Lesser General Public License v3.0
23 stars 13 forks source link

Fix memory leak if return type is strv with container transfer mode #35

Closed ximion closed 3 years ago

ximion commented 3 years ago

Hi! Functions may return a const gchar** with (transfer container), in which case the caller has to free the surrounding "container" with g_free to not create a memory leak. This patch makes gir-to-d follow that behavior. I include the glib.c.functions module now for g_free - using Str.freeString would also have worked, as that just calls g_free, but that would have required a typecast, and we are freeing a memory segment here and not a string, so I found just using g_free to be more appropriate. Cheers, Matthias

MikeWey commented 3 years ago

Thanks.

ximion commented 3 years ago

This problem likely also exists for container transfers of GPtrArray & Co., but fixing that is less straightforward.