memory freeing necessary?

David Zeuthen david at fubar.dk
Sat Jul 22 08:13:53 PDT 2006


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. 

Cheers,
David




More information about the hal mailing list