On Fri, Jul 30, 2010 at 3:13 PM, Darryl L. Pierce dpierce@redhat.com wrote:
On Fri, Jul 30, 2010 at 02:06:02PM +0200, Andrew Beekhof wrote:
No objections.
One minor thing, the if-clause is redundant for the calls to free().
I don't think so. The first one does a free() on the original buffer allocated if the buffer was too small for the API. The second call releases memory being held by the buffer regardless of which path it took. Though, in thinking about it, the call ought to be replaced with a macro that releases the memory and then sets the pointer to NULL to avoid any future change trying to double-release memory.
Correct.
The if-clause can't help protect you from multiple free()s. It only becomes relevant if you set the pointer back to NULL, but then it still has no effect because free(NULL) is perfectly legal.
Presumably ret_length contains the length required not the length returned?
Correct. It's the way the API returns the length needed if the originally allocated buffer is too small.
I'll push this with a macro for the call to free().
-- Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc. Delivering value year after year. Red Hat ranks #1 in value among software vendors. http://www.redhat.com/promo/vendor/