- add gkrellm_store_chartdatav() that takes a va_list instead of varargs. This fixes a potential crash caused by plugins using gkrellm_store_chartdata on win32 (same problem as with gkrellm_debug(), the win32 plugin-interface needs a va_list version of every vararg function in gkrellm).

This commit is contained in:
Stefan Gehn 2008-12-27 13:21:11 +00:00
parent 0d35922472
commit abcce9a6b1
5 changed files with 33 additions and 17 deletions

View File

@ -67,7 +67,7 @@ static gint
computed_index(GkrellmChart *cp, gint i)
{
gint x;
x = (cp->position + i + 1) % cp->w;
return x;
}
@ -272,7 +272,7 @@ chartdata_ycoord(GkrellmChart *cp, GkrellmChartdata *cd, gint yd)
{
glong y;
guint64 Y;
if (cp->scale_max <= 0)
cp->scale_max = 1;
@ -809,6 +809,17 @@ void
gkrellm_store_chartdata(GkrellmChart *cp, gulong total, ...)
{
va_list args;
if (!cp)
return;
va_start(args, total);
gkrellm_store_chartdatav(cp, total, args);
va_end(args);
}
void
gkrellm_store_chartdatav(GkrellmChart *cp, gulong total, va_list args)
{
GList *list;
GkrellmChartdata *cd;
gulong range, total_diff;
@ -818,10 +829,10 @@ gkrellm_store_chartdata(GkrellmChart *cp, gulong total, ...)
if (!cp)
return;
va_start(args, total);
for (list = cp->cd_list; list; list = list->next)
{
cd = (GkrellmChartdata *) list->data;
//FIXME: missing check for number of passed varargs passed in "args"
cd->current = va_arg(args, gulong);
if (!cd->monotonic)
{
@ -833,12 +844,11 @@ gkrellm_store_chartdata(GkrellmChart *cp, gulong total, ...)
if (cd->current < cd->previous || !cp->primed)
cd->previous = cd->current;
}
va_end(args);
if (total < cp->previous_total || !cp->primed)
cp->previous_total = total; /* Wrap around, this store won't scale */
total_diff = total - cp->previous_total;
cp->previous_total = total;
/* Increment position in circular buffer and remember the data
| value to be thrown out.
*/
@ -1163,7 +1173,7 @@ gkrellm_draw_chart_text(GkrellmChart *cp, gint style_id, gchar *str)
buf[text_length] = '\0';
printf("draw_chart_text: [%s] ", buf);
}
offset = cp->baseline_ref - tr->baseline; /* align baselines */
if (_GK.chart_text_no_fill)
gkrellm_draw_text(cp->pixmap, ts, x, y + offset, s,
@ -1834,7 +1844,7 @@ gkrellm_chart_create(GtkWidget *vbox, GkrellmMonitor *mon, GkrellmChart *cp,
cp->config->chart_cd_list = &cp->cd_list;
if (!cp->box)
{
{
cp->box = gtk_vbox_new(FALSE, 0); /* not a hbox anymore !! */
gtk_box_pack_start(GTK_BOX(vbox), cp->box, FALSE, FALSE, 0);
@ -2015,7 +2025,7 @@ set_grid_resolution_spin_button(GkrellmChart *cp, gint res)
if (!cp || !cp->config_window || !cp->config->grid_resolution_spin_button)
return;
spin = GTK_SPIN_BUTTON(cp->config->grid_resolution_spin_button);
gtk_spin_button_set_value(spin, (gfloat) res);
gtk_spin_button_set_value(spin, (gfloat) res);
}
static void

View File

@ -93,6 +93,7 @@ GkrellmChartdata *gkrellm_add_chartdata(GkrellmChart *, GdkPixmap **,
GkrellmChartdata *gkrellm_add_default_chartdata(GkrellmChart *, gchar *);
void gkrellm_alloc_chartdata(GkrellmChart *);
void gkrellm_store_chartdata(GkrellmChart *, gulong, ...);
void gkrellm_store_chartdatav(GkrellmChart *cp, gulong total, va_list args);
void gkrellm_draw_chartdata(GkrellmChart *);
void gkrellm_monotonic_chartdata(GkrellmChartdata *, gboolean);
gboolean gkrellm_get_chartdata_hide(GkrellmChartdata *);
@ -269,7 +270,7 @@ GkrellmDecalbutton *gkrellm_make_scaled_button(GkrellmPanel *p,
gboolean auto_hide, gboolean set_default_border,
gint depth, gint cur_index, gint pressed_index,
gint x, gint y, gint w, gint h);
GkrellmDecalbutton *gkrellm_decal_is_button(GkrellmDecal *);
void gkrellm_set_in_button_callback(GkrellmDecalbutton *,
gint (*func)(), gpointer data);
@ -571,7 +572,7 @@ gboolean gkrellm_disk_temperature_display(gpointer sr, gchar *disk_name,
gfloat t, gchar units);
void gkrellm_disk_temperature_remove(gchar *disk_name);
/* Functions exported by net.c
*/
gint gkrellm_net_routes(void);

View File

@ -195,12 +195,16 @@ void gkrellm_alloc_chartdata(GkrellmChart *a)
{
(*(callbacks->gkrellm_alloc_chartdata))(a);
}
void gkrellm_store_chartdata(GkrellmChart *a, gulong b, ...)
void gkrellm_store_chartdata(GkrellmChart *cp, gulong total, ...)
{
va_list ap;
va_start(ap, b);
callbacks->gkrellm_store_chartdata(a, b, ap);
va_end(ap);
va_list args;
va_start(args, total);
callbacks->gkrellm_store_chartdatav(cp, total, args);
va_end(args);
}
void gkrellm_store_chartdatav(GkrellmChart *cp, gulong total, va_list args)
{
callbacks->gkrellm_store_chartdatav(cp, total, args);
}
void gkrellm_draw_chartdata(GkrellmChart *a)
{

View File

@ -82,7 +82,7 @@ void win32_init_callbacks(void)
gkrellm_callbacks.gkrellm_add_chartdata = gkrellm_add_chartdata;
gkrellm_callbacks.gkrellm_add_default_chartdata = gkrellm_add_default_chartdata;
gkrellm_callbacks.gkrellm_alloc_chartdata = gkrellm_alloc_chartdata;
gkrellm_callbacks.gkrellm_store_chartdata = gkrellm_store_chartdata;
gkrellm_callbacks.gkrellm_store_chartdatav = gkrellm_store_chartdatav;
gkrellm_callbacks.gkrellm_draw_chartdata = gkrellm_draw_chartdata;
gkrellm_callbacks.gkrellm_monotonic_chartdata = gkrellm_monotonic_chartdata;
gkrellm_callbacks.gkrellm_get_chartdata_hide = gkrellm_get_chartdata_hide;

View File

@ -82,7 +82,8 @@ typedef struct
GdkPixmap *, gchar *);
GkrellmChartdata *(*gkrellm_add_default_chartdata)(GkrellmChart *, gchar *);
void (*gkrellm_alloc_chartdata)(GkrellmChart *);
void (*gkrellm_store_chartdata)(GkrellmChart *, gulong, ...);
// gkrellm_store_chartdata is not called from libgkrellm, only gkrellm_store_chartdatav
void (*gkrellm_store_chartdatav)(GkrellmChart *, gulong, ...);
void (*gkrellm_draw_chartdata)(GkrellmChart *);
void (*gkrellm_monotonic_chartdata)(GkrellmChartdata *, gboolean);
gboolean (*gkrellm_get_chartdata_hide)(GkrellmChartdata *);