On Mon, Nov 19, 2007 at 10:45:53PM -0500, "K. Piche" <kpiche@rogers.com> wrote:
And that is my point. We don't have a clear definition of what needs freeing and what does not. The name "alpm_db_whatprovides" doesn't indicate at all that its result needs to be freed, and yet something like "alpm_fetch_pkgurl" doesn't need freeing (or does it? I don't know and that seems problematic).
So yes, it comes down to documentation and good function naming, which we lack. :)
You could have a simple convention like GTK/GNOME stuff does: any function arguments or returns that are "const" should not be freed by the user (or front end in this case). See "Cleanliness" in http://developer.gnome.org/doc/guides/programming-guidelines/code-style.html
or just use __attribute__ ((__warn_unused_result__)) on those functions. obviously those functions' return value must be free'd. - VMiklos