[PATCH] Link following implementation + test fixes

Jim Meyering jim at meyering.net
Thu Oct 14 06:17:00 UTC 2010


Jeff Darcy wrote:
> On 10/13/2010 04:50 PM, Jim Meyering wrote:
>>> diff --git a/replica.c b/replica.c
...
>> Rather than modifying the caller's buffer, even
>> only temporarily, it seems like it'd be cleaner
>> to make the "object" parameter const too, and operate on
>> a strdup'd copy.
>
> The only place this gets called is from the expression evaluator, which
> got the value as part of a T_OFIELD/T_SFIELD/T_LINK expression.  That
> means it's already likely to be a strdup'ed value from a previous
> invocation of meta_get_value, so nobody else has that pointer and the
> evaluator will definitely wait for follow_link to return before looking
> at it again.  (It *could* be a permanent value for T_SFIELD but I can't
> imagine why anyone would use the link construct that way and it might
> even make sense to disallow it.)  So yes, it might be cleaner in a
> general-practice kind of way, but is the extra trip through malloc/free
> worth it?  There are already more of those per request than I'd really like.

Thought the "const" and extra malloc/free would be in line with
a style that marks even pointers to strdup'd buffers as "const".
But either way is fine with me.


More information about the iwhd-devel mailing list