summaryrefslogtreecommitdiff
path: root/navit/map.c
diff options
context:
space:
mode:
authortegzed <tegzed@ffa7fe5e-494d-0410-b361-a75ebd5db220>2011-03-19 22:22:12 +0000
committertegzed <tegzed@ffa7fe5e-494d-0410-b361-a75ebd5db220>2011-03-19 22:22:12 +0000
commit8b9d704e01ac33d16972ad6ab71d8d6b350fa12e (patch)
tree85963d1a3566c89c05e8aea0d3fdfea17374887d /navit/map.c
parent444e54ef8c640ecaf29becacc67d4abf3e259451 (diff)
downloadnavit-8b9d704e01ac33d16972ad6ab71d8d6b350fa12e.tar.gz
Add:core: - Added reference counting map destruction mechanism
- Added item creation function to the map interface git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@4370 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/map.c')
-rw-r--r--navit/map.c46
1 files changed, 41 insertions, 5 deletions
diff --git a/navit/map.c b/navit/map.c
index a991bdf40..d8ca5e363 100644
--- a/navit/map.c
+++ b/navit/map.c
@@ -61,6 +61,7 @@ struct map {
struct map_priv *priv; /**< Private data of the map, only known to the map plugin */
struct attr **attrs; /**< Attributes of this map */
struct callback_list *attr_cbl; /**< List of callbacks that are called when attributes change */
+ int refcount;
};
/**
@@ -112,9 +113,19 @@ map_new(struct attr *parent, struct attr **attrs)
map_destroy(m);
m=NULL;
}
+ else {
+ m->refcount = 0;
+ }
return m;
}
+void
+map_ref(struct map* m)
+{
+ m->refcount++;
+}
+
+
/**
* @brief Gets an attribute from a map
*
@@ -247,6 +258,16 @@ map_set_projection(struct map *this_, enum projection pro)
this_->meth.pro=pro;
}
+void
+map_destroy_do(struct map *m)
+{
+ if (m->priv)
+ m->meth.map_destroy(m->priv);
+ attr_list_free(m->attrs);
+ callback_list_destroy(m->attr_cbl);
+ g_free(m);
+}
+
/**
* @brief Destroys an opened map
*
@@ -255,11 +276,12 @@ map_set_projection(struct map *this_, enum projection pro)
void
map_destroy(struct map *m)
{
- if (m->priv)
- m->meth.map_destroy(m->priv);
- attr_list_free(m->attrs);
- callback_list_destroy(m->attr_cbl);
- g_free(m);
+ if(0<m->refcount) {
+ m->refcount--;
+ }
+ if(0 == m->refcount) {
+ map_destroy_do(m);
+ }
}
/**
@@ -672,3 +694,17 @@ map_dump(struct map *map)
{
map_dump_filedesc(map, stdout);
}
+
+struct item *
+map_rect_create_item(struct map_rect *mr, enum item_type type_)
+{
+ if(mr && mr->priv && mr->m) {
+ return mr->m->meth.map_rect_create_item(mr->priv, type_) ;
+ }
+ else {
+ return NULL;
+ }
+}
+
+
+