On 11/24/2011 07:13 PM, Richard W.M. Jones wrote:
On Thu, Nov 24, 2011 at 02:48:46PM +0000, Matthew Booth wrote:
> Select non-comment labels using an augeas path to return the correct nodes in
> the first instance, rather than applying a regular expression to all results.
> Iterate over returned matches using a char** iterator.
> Use asprintf() to ensure the path string buffer is the correct size.
In general this is an obvious improvement.
> + for (char **entry = entries; *entry != NULL; entry++) {
> + if (asprintf (&augpath, "%s/spec", *entry) == -1)
g->abort_cb();
We have a safe_asprintf function defined already, and it would be
better to use that.
Is augpath supposed to be freed on the non-error path?
spec and mp should be freed on the error path, but don't seem to be at
the moment.
I was mis-remembering the definition of asprintf(). I thought it was
doing a realloc() on the buffer you passed in, but reading it again I
don't see that. I'll respin it.
Matt
--
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team
GPG ID: D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490