summaryrefslogtreecommitdiff
path: root/navit/config_.c
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2010-05-09 08:34:57 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2010-05-09 08:34:57 +0000
commit2ad31a7780f0ebbd00f5765b847b2caa72349239 (patch)
tree5e24927bd0393860302eec734dbc4a59139373a5 /navit/config_.c
parentbe6be79f69be4afff92df533375ab8160603ed81 (diff)
downloadnavit-svn-2ad31a7780f0ebbd00f5765b847b2caa72349239.tar.gz
Fix:Core:Don't crash with binding dbus statically linked
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@3233 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/config_.c')
-rw-r--r--navit/config_.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/navit/config_.c b/navit/config_.c
index 16774283..bab343c1 100644
--- a/navit/config_.c
+++ b/navit/config_.c
@@ -31,6 +31,8 @@ struct config {
int config_empty_ok;
+static int configured;
+
struct attr_iter {
void *iter;
};
@@ -44,6 +46,13 @@ config_destroy(struct config *this_)
exit(0);
}
+static void
+config_new_int(void)
+{
+ config=g_new0(struct config, 1);
+ config->cbl=callback_list_new();
+}
+
int
config_get_attr(struct config *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
{
@@ -71,6 +80,8 @@ config_set_attr(struct config *this_, struct attr *attr)
int
config_add_attr(struct config *this_, struct attr *attr)
{
+ if (!config)
+ config_new_int();
switch (attr->type) {
case attr_callback:
callback_list_add(this_->cbl, attr->u.callback);
@@ -110,7 +121,7 @@ config_attr_iter_destroy(struct attr_iter *iter)
struct config *
config_new(struct attr *parent, struct attr **attrs)
{
- if (config) {
+ if (configured) {
dbg(0,"only one config allowed\n");
return NULL;
}
@@ -118,9 +129,9 @@ config_new(struct attr *parent, struct attr **attrs)
dbg(0,"no parent in config allowed\n");
return NULL;
}
- config=g_new0(struct config, 1);
+ if (!config)
+ config_new_int();
config->attrs=attr_list_dup(attrs);
- config->cbl=callback_list_new();
while (*attrs) {
if (!config_set_attr_int(config,*attrs)) {
dbg(0,"failed to set attribute '%s'\n",attr_to_name((*attrs)->type));
@@ -130,5 +141,6 @@ config_new(struct attr *parent, struct attr **attrs)
}
attrs++;
}
+ configured=1;
return config;
}