[rrd-developers] getting new RRA entries since last update

Sebastian Harl sh at tokkee.org
Wed Apr 14 13:17:21 CEST 2010


Heya,

On Wed, Apr 14, 2010 at 11:33:49AM +0200, Frederik Kriewitz wrote:
> rrd_update_v() works but results in some ugly code including a malloc
> which souldn't be necessary:
> 
> /* We need to use rrd_update_v and construct update_argv because
>    rrd_update_r doesn't allow us to use the rrd_info_t * pcdp_summary
>    parameter of _rrd_update() */
> int update_argc = values_num + 2;
> char **update_argv = (char**) malloc (update_argc * sizeof (char*));
> if (update_argv == NULL)
> {
[…]
> }
> else
> {
[…]
>   free(update_argv);
> }

In fact, that malloc can be avoided (using C99 features [1]):

  int update_argc = values_num + 2;
  char *update_argv[update_argc];

*SCNR*

Cheers,
Sebastian

[1] <http://en.wikipedia.org/wiki/Variable-length_array>

-- 
Sebastian "tokkee" Harl +++ GnuPG-ID: 0x8501C7FC +++ http://tokkee.org/

Those who would give up Essential Liberty to purchase a little Temporary
Safety, deserve neither Liberty nor Safety.         -- Benjamin Franklin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://lists.oetiker.ch/pipermail/rrd-developers/attachments/20100414/3aa31edb/attachment-0001.pgp 


More information about the rrd-developers mailing list