memory freeing necessary?

Richard Hughes hughsient at gmail.com
Sat Jul 22 10:11:00 PDT 2006


On Sat, 2006-07-22 at 11:13 -0400, David Zeuthen wrote:
> On Fri, 2006-07-21 at 13:48 +0200, Andre Puschmann wrote:
> > hi folks,
> > i am using hal in an application to figure out if the system supports
> > hibernate/suspend.
> > 
> > i had a look at lshal.c and hal_get_property.c to figure out how all the
> > hal and dbus stuff works and i am wondering about how error handling
> > (e.g. freeing memory) is being done.
> > if for instance libhal_ctx_init() fails (if hald isn't running) isn't it
> > necessary to free hal_ctx or dbusConnection in order to avoid a memory leak?
> 
> Indeed it is. The pattern we're trying to use is that the caller frees
> anything it callee returns unless it's explicitly marked as const. We
> also try to document this in libhal and libhal-storage, patches welcome
> to improve the documentation.
> 
> Another avenue is to just not use libhal, libhal-storage but use D-BUS
> directly and then whether memory is freed is up to how the bindings for
> your language works. 

I've got quite a nice libhal-glib implementation if you think this is
useful to have in hal. It's a standard singleton gobject, so desktop
applications can just receive standard signals on a gobject and not have
to worry about dbus at all (as some of the stuff like using
PropertyModified is pretty gruesome...)
It's pretty lightweight, and converts the odd types such as char ***
into 'friendly' GLists and other nice stuff.

What you think? Want a patch?

R.




More information about the hal mailing list