diff options
author | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2012-02-06 13:50:30 +0000 |
---|---|---|
committer | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2012-02-06 13:50:30 +0000 |
commit | 1077f568756b00c10af6a0dfabebe49a2c7cf4a0 (patch) | |
tree | 3bbccc25a229f475de4b645d57861d7caffedd8a /navit/attr.c | |
parent | fd5dc6e76fcac67ae547ca2321c4c77f26b9603a (diff) | |
download | navit-1077f568756b00c10af6a0dfabebe49a2c7cf4a0.tar.gz |
Add:Core:Implement reference counting for navit object
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@4926 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/attr.c')
-rw-r--r-- | navit/attr.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/navit/attr.c b/navit/attr.c index c4ed00db3..894f01bff 100644 --- a/navit/attr.c +++ b/navit/attr.c @@ -32,6 +32,7 @@ #include "endianess.h" #include "util.h" #include "types.h" +#include "xmlconfig.h" struct attr_name { enum attr_type attr; @@ -568,6 +569,11 @@ attr_free(struct attr *attr) { if (!attr) return; + if (attr->type == attr_navit || attr->type == attr_vehicle) { + struct navit_object *obj=attr->u.data; + if (obj && obj->func && obj->func->unref) + obj->func->unref(obj); + } if (!(attr->type >= attr_type_int_begin && attr->type <= attr_type_int_end) && !(attr->type >= attr_type_object_begin && attr->type <= attr_type_object_end)) g_free(attr->u.data); @@ -581,9 +587,16 @@ attr_dup_content(struct attr *src, struct attr *dst) dst->type=src->type; if (src->type >= attr_type_int_begin && src->type <= attr_type_int_end) dst->u.num=src->u.num; - else if (src->type >= attr_type_object_begin && src->type <= attr_type_object_end) - dst->u.data=src->u.data; - else { + else if (src->type >= attr_type_object_begin && src->type <= attr_type_object_end) { + if (src->type == attr_navit || src->type == attr_vehicle) { + struct navit_object *obj=src->u.data; + if (obj && obj->func && obj->func->ref) { + dst->u.data=obj->func->ref(obj); + } else + dst->u.data=obj; + } else + dst->u.data=src->u.data; + } else { size=attr_data_size(src); if (size) { dst->u.data=g_malloc(size); |