diff options
author | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2010-05-09 08:34:57 +0000 |
---|---|---|
committer | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2010-05-09 08:34:57 +0000 |
commit | d9a8c65f9bea4c57fa149a152d81c1864e49ca03 (patch) | |
tree | 5e24927bd0393860302eec734dbc4a59139373a5 /navit/config_.c | |
parent | 5967b6108e588c0077d4199647525f28a7bd54d2 (diff) | |
download | navit-d9a8c65f9bea4c57fa149a152d81c1864e49ca03.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_.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/navit/config_.c b/navit/config_.c index 167742833..bab343c13 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; } |