RIF: org.freedesktop.DBus.GLib.ReturnVal frees returns value

Havoc Pennington hp at redhat.com
Fri Sep 15 11:13:47 PDT 2006


Frederic Heem wrote:
> Dbus freeing the return value has at least 2 problems:
> * If the application returns a static buffer, the application will crash when dbus frees the static buffer.

Then the application needs to call g_strdup.

> * The malloc/free mismatch: the application could use its own allocation mechanism and the free function that dbus uses cannot know how to deallocate the memory.

Then the application needs to call g_strdup also.

The normal assumption with the glib bindings however is that you are 
using g_malloc, that's part of what makes glib-based apps convenient.

If you use libdbus directly instead of the glib bindings, then you can 
manually handle memory allocation however you want, of course.

> If dbus really wants to free the return value, first it has to be clearly documented

The glib bindings have no docs really, nor are they really finished or 
adequately maintained IMO. Of course anyone is more than welcome to 
write the docs!

Havoc



More information about the dbus mailing list