aboutsummaryrefslogtreecommitdiffstats
path: root/widget.c
diff options
context:
space:
mode:
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2004-01-13 08:18:20 +0000
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2004-01-13 08:18:20 +0000
commit3cac7824479e0eef3b0bc6e33e5b4d157119a646 (patch)
tree50b1ca62db5a55df61dcea29017a1852d1e01f9b /widget.c
parent14bc006adad8578e31e557d7ffb57971284a0846 (diff)
downloadlcd4linux-3cac7824479e0eef3b0bc6e33e5b4d157119a646.tar.gz
[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
Diffstat (limited to 'widget.c')
-rw-r--r--widget.c41
1 files changed, 37 insertions, 4 deletions
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 <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <errno.h>
#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; i<nClasses; i++) {
if (strcasecmp(widget->name, 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<nClasses; i++) {
if (strcasecmp(class, Classes[i].name)==0) {
Class=&(Classes[i]);
@@ -123,9 +141,24 @@ int widget_add (char *name)
return -1;
}
+ // do NOT use realloc here because there may be pointers to the old
+ // memory area, which would point to nirvana if realloc moves the area
+ if (Widgets==NULL) {
+ Widgets=malloc(MAX_WIDGETS*sizeof(WIDGET));
+ if (Widgets==NULL) {
+ error ("internal error: allocation of widget buffer failed: %s", strerror(errno));
+ return -1;
+ }
+ }
+
+ // another sanity check
+ if (nWidgets>=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;
mp;follow=1'>d/control: various fixes found by libconfig-model-dpkg-perlJonathan McCrohan2-5/+13 2015-04-01Release 0+git20150208.f2053b3-1Jonathan McCrohan1-2/+2 2015-04-01Describe changes made in snapshotJonathan McCrohan1-0/+3 2015-04-01New Upstream Snapshot (commit f2053b3)Jonathan McCrohan1-0/+6 2015-04-01Imported Upstream version 0+git20150208.f2053b3upstream/0+git20150208.f2053b3Jonathan McCrohan32-333/+483 2014-12-28Release 0+git20141218.b46a22c-1debian/0+git20141218.b46a22c-1Jonathan McCrohan1-2/+2 2014-12-28Updated AU DVB-T files; Thanks Brian Burch! (Closes LP: #1393280)Jonathan McCrohan1-0/+1 2014-12-28New Upstream Snapshot (commit b46a22c)Jonathan McCrohan1-0/+6 2014-12-28Imported Upstream version 0+git20141218.b46a22cupstream/0+git20141218.b46a22cJonathan McCrohan535-639/+317 2014-10-20Release 0+git20141009.d26b627-1debian/0+git20141009.d26b627-1Jonathan McCrohan1-2/+2 2014-10-20Fix up packaging to account for move to DVBv5Jonathan McCrohan2-2/+6 2014-10-20delete d/dtv-scan-files.install; Upstream now supplies a MakefileJonathan McCrohan2-4/+1 2014-10-15d/control: update Standards Version to 3.9.6Jonathan McCrohan2-1/+3 2014-10-15d/control: add Build-Depends on dvb-toolsJonathan McCrohan2-1/+2 2014-10-15New Upstream Snapshot (commit d26b627)Jonathan McCrohan1-0/+10 2014-10-15Imported Upstream version 0+git20141009.d26b627upstream/0+git20141009.d26b627Jonathan McCrohan2010-11120/+159271 2014-07-23Release 0+git20140611.14bd6c7-1debian/0+git20140611.14bd6c7-1Jonathan McCrohan1-2/+2 2014-07-23New Upstream Snapshot (commit 14bd6c7)Jonathan McCrohan1-2/+3 2014-07-23Imported Upstream version 0+git20140611.14bd6c7upstream/0+git20140611.14bd6c7Jonathan McCrohan7-11/+60 2014-05-13New Upstream Snapshot (commit 1246b27)Jonathan McCrohan1-0/+6 2014-05-13Imported Upstream version 0+git20140512.1246b27upstream/0+git20140512.1246b27Jonathan McCrohan391-301/+3983 2014-04-05Release 0+git20140326.cfc2975-1debian/0+git20140326.cfc2975-1Jonathan McCrohan1-2/+2 2014-04-05d/control: update Homepage (upstream has moved from Gitweb to cgit)Jonathan McCrohan2-1/+2 2014-04-05New Upstream Snapshot (commit cfc2975)Jonathan McCrohan1-0/+6 2014-04-05Imported Upstream version 0+git20140326.cfc2975upstream/0+git20140326.cfc2975Jonathan McCrohan118-656/+877 2014-01-16Release 0+git20140107.1850cf8-1debian/0+git20140107.1850cf8-1Jonathan McCrohan1-2/+2 2014-01-16Update Standards Version to 3.9.5Jonathan McCrohan2-1/+9