[collectd] [PATCH] src/csv.c: use a bigger buffer

Grzegorz Nosek root at localdomain.pl
Wed Jul 27 13:46:44 CEST 2011


W dniu 27.07.2011 13:37, Florian Forster pisze:
> Hi Colin,
>
> thank you very much for your patch!
>
> On Mon, Jul 25, 2011 at 05:00:07PM -0700, Colin McCabe wrote:
>> -	char         values[512];
>> +	char         *values = NULL;
>
> Why don't use stick with stack memory here? Allocating a (fixed sized)
> junk on the heap only means that you'll have to free it again.

Maybe the buffer could be resized if it's too small? That would be a 
benefit of a heap allocation (not done in the patch AFAICS).

>> -		return (-1);
>> +		goto fail;
>
> Sorry, but "goto" is a no-go for collectd. You can use something like
> "do { … } while (0);" if you must, but in this particular case I think
> simply using stack memory is the way to go.

Is using goto to clean up and return considered evil too? ;) It's well 
established and preferred e.g. in Linux kernel code. I'd say it's a 
reasonable approximation of a try/finally block from other languages.

Best regards,
  Grzegorz Nosek

BTW, should I resend my network plugin patches or have you seen them and 
deemed bad for any reason?



More information about the collectd mailing list