From 3cac7824479e0eef3b0bc6e33e5b4d157119a646 Mon Sep 17 00:00:00 2001 From: reinelt Date: Tue, 13 Jan 2004 08:18:20 +0000 Subject: [lcd4linux @ 2004-01-13 08:18:07 by reinelt] timer queues added liblcd4linux deactivated turing transformation to new layout git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@308 3ae390bd-cb1e-0410-b409-cd5a39f66f1f --- widget.c | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) (limited to 'widget.c') diff --git a/widget.c b/widget.c index 60414fe..57a4b5b 100644 --- a/widget.c +++ b/widget.c @@ -1,4 +1,4 @@ -/* $Id: widget.c,v 1.6 2004/01/11 18:26:02 reinelt Exp $ +/* $Id: widget.c,v 1.7 2004/01/13 08:18:20 reinelt Exp $ * * generic widget handling * @@ -21,6 +21,10 @@ * * * $Log: widget.c,v $ + * Revision 1.7 2004/01/13 08:18:20 reinelt + * timer queues added + * liblcd4linux deactivated turing transformation to new layout + * * Revision 1.6 2004/01/11 18:26:02 reinelt * further widget and layout processing * @@ -57,26 +61,39 @@ #include #include #include +#include #include "debug.h" #include "cfg.h" #include "widget.h" +// we use a static array of widgets and not realloc() +#define MAX_WIDGETS 256 + static WIDGET_CLASS *Classes=NULL; static int nClasses=0; static WIDGET *Widgets=NULL; static int nWidgets=0; +static int widget_added=0; int widget_register (WIDGET_CLASS *widget) { int i; + // sanity check: disallow widget registering after at least one + // widget has been added, because we use realloc here, and there may + // be pointers to the old memory area + if (widget_added) { + error ("internal error: register_widget(%s) after add_widget()", widget->name); + return -1; + } + for (i=0; iname, Classes[i].name)==0) { - error ("internal error: widget '%s' already exists!"); + error ("internal error: widget '%s' already exists!", widget->name); return -1; } } @@ -112,6 +129,7 @@ int widget_add (char *name) } // lookup widget class + Class=NULL; for (i=0; i=MAX_WIDGETS) { + error ("internal error: widget buffer full!"); + return -1; + } + + Widget=&(Widgets[nWidgets]); nWidgets++; - Widgets=realloc(Widgets, nWidgets*sizeof(WIDGET)); - Widget=&(Widgets[nWidgets-1]); Widget->name = name; Widget->class = Class; -- cgit v1.2.3