On 21 July 2015 at 16:37, James Greenhalgh <james.greenha...@arm.com> wrote:
> On Thu, Jul 16, 2015 at 04:20:59PM +0100, Kyrill Tkachov wrote:

>> +static bool
>> +aarch64_process_one_target_attr (char *arg_str, const char* pragma_or_attr)
>> +{
>> +  bool ret;
>> +  bool invert = false;
>> +
>> +  int len = strlen (arg_str);
>> +
>> +  if (len == 0)
>> +    {
>> +      error ("malformed target %s", pragma_or_attr);
>> +      return false;
>> +    }
>> +
>> +  char *str_to_check = (char *) alloca (len + 1);
>
> Seems to go against your approach earlier in the patch series of XSTRDUP,
> it would be nice to stay consistent.

Agreed, we should be consistent.  Each of the other instances of
alloca/xstrdup that I've seen in this patch series are actually
superflous, we simply copy the string, use it then bin it, better to
remove the dup completely.

In the choice between xstrdup() and alloca(), since alloca() is an
option, better to choose alloca() and remove the need for each of the
explicit free() calls in the exit paths. The alloca() route  makes it
less likely that we accidentally introduce a space leak in the future.

Cheers
/Marcus

Reply via email to