From: Sebastian Harl Date: Wed, 14 Nov 2012 18:05:10 +0000 (+0100) Subject: perl plugin: Simplified $interval_g implementation. X-Git-Tag: collectd-5.2.0~20^2~4 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=c6d5db799a2b4a8050ee9251eade254cb9b7f695;p=collectd.git perl plugin: Simplified $interval_g implementation. Don't pass any pointers to interval_g around just in order to later dereference them. There's just no reason to do so ;-) --- diff --git a/src/perl.c b/src/perl.c index e5dc6c75..924cb63f 100644 --- a/src/perl.c +++ b/src/perl.c @@ -2120,23 +2120,14 @@ static int g_pv_set (pTHX_ SV *var, MAGIC *mg) static int g_interval_get (pTHX_ SV *var, MAGIC *mg) { - cdtime_t *interval = (cdtime_t *)mg->mg_ptr; - double nv; - - nv = CDTIME_T_TO_DOUBLE (*interval); - - sv_setnv (var, nv); + sv_setnv (var, CDTIME_T_TO_DOUBLE (interval_g)); return 0; } /* static int g_interval_get (pTHX_ SV *, MAGIC *) */ static int g_interval_set (pTHX_ SV *var, MAGIC *mg) { - cdtime_t *interval = (cdtime_t *)mg->mg_ptr; - double nv; - - nv = (double)SvNV (var); - - *interval = DOUBLE_TO_CDTIME_T (nv); + double nv = (double)SvNV (var); + interval_g = DOUBLE_TO_CDTIME_T (nv); return 0; } /* static int g_interval_set (pTHX_ SV *, MAGIC *) */ @@ -2192,7 +2183,7 @@ static void xs_init (pTHX) tmp = get_sv ("Collectd::interval_g", /* create = */ 1); sv_magicext (tmp, NULL, /* how = */ PERL_MAGIC_ext, /* vtbl = */ &g_interval_vtbl, - /* name = */ (char *) &interval_g, /* namelen = */ 0); + /* name = */ NULL, /* namelen = */ 0); return; } /* static void xs_init (pTHX) */