Summary: | Document that dbus_g_method_get_sender's return needs freeing | ||
---|---|---|---|
Product: | dbus | Reporter: | frederic heem <frederic.heem> |
Component: | GLib | Assignee: | Rob Taylor <rob.taylor> |
Status: | RESOLVED FIXED | QA Contact: | John (J5) Palmieri <johnp> |
Severity: | normal | ||
Priority: | high | ||
Version: | unspecified | ||
Hardware: | Other | ||
OS: | Linux (All) | ||
Whiteboard: | |||
i915 platform: | i915 features: | ||
Attachments: | dbus_g_method_get_sender-return-const-char.txt |
Description
frederic heem
2006-10-30 06:32:57 UTC
Created attachment 7588 [details] [review] dbus_g_method_get_sender-return-const-char.txt No. Could you please explain why ? Because that memory is freed as soon as the message is discarded, it breaks api, and breaks exitig code. Why dbus-glib imposes the burden of freeing the memory allocated by dbus-glib ? Anyway, an application must not use the free function of pointer allocated by a library. The library shall provide an API to free it itself. Moreover, the memory is not freed when the message is discarded. There is nowhere that dbus-glib could free this sensibly. Its standard glib practice in such cases that the client code frees the memory (using g_free). The memory returned by dbus_message_get_sender is a pointer to the string within the message itself. In the core bindings its fine for dbus_message_get_sender to return const char* as the user is managing the message lifetime herself, but in dbus-glib the user should never have to worry about message lifetime (or indeed messages) so hence the string duplication. Fine, but please document the function that the returned pointer has to be freed with g_free. Agreed, renamed and reopened bug appropriately Fixed in git head. |
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.