summaryrefslogtreecommitdiff
path: root/navit/mapset.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/mapset.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/mapset.c')
-rw-r--r--navit/mapset.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/navit/mapset.c b/navit/mapset.c
index 9c6c6a1be..bc0dd09bc 100644
--- a/navit/mapset.c
+++ b/navit/mapset.c
@@ -87,6 +87,7 @@ mapset_add_attr(struct mapset *ms, struct attr *attr)
switch (attr->type) {
case attr_map:
ms->maps=g_list_append(ms->maps, attr->u.map);
+ map_ref(attr->u.map);
return 1;
default:
return 0;
@@ -147,6 +148,12 @@ static void mapset_maps_free(struct mapset *ms)
*/
void mapset_destroy(struct mapset *ms)
{
+ GList *map;
+ map=ms->maps;
+ while (map) {
+ map_destroy(map->data);
+ map=g_list_next(map);
+ }
g_free(ms);
}
@@ -224,6 +231,34 @@ struct map * mapset_next(struct mapset_handle *msh, int active)
}
/**
+ * @brief Gets a map from the mapset by name
+ *
+ * @param ms The map
+ * @param map_name the map name used by the search
+ * @return The next map
+ */
+struct map *
+mapset_get_map_by_name(struct mapset *ms, char*map_name)
+{
+ struct mapset_handle*msh;
+ struct map*curr_map;
+ struct attr map_attr;
+ if( !ms || !map_name ) {
+ return NULL;
+ }
+ msh=mapset_open(ms);
+ while ((curr_map=mapset_next(msh, 1))) {
+ //get map name
+ if(map_get_attr(curr_map,attr_name, &map_attr,NULL)) {
+ if( ! strcmp(map_attr.u.str, map_name)) {
+ break;
+ }
+ }
+ }
+ return curr_map;
+}
+
+/**
* @brief Closes a mapset handle after it is no longer used
*
* @param msh Mapset handle to be closed