Diff of /trunk/src/osm.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 237 by harbaum, Wed Jul 22 15:01:53 2009 UTC revision 238 by harbaum, Wed Jul 22 20:14:48 2009 UTC
# Line 204  gboolean osm_way_ends_with_node(way_t *w Line 204  gboolean osm_way_ends_with_node(way_t *w
204    
205  /* ------------------- node handling ------------------- */  /* ------------------- node handling ------------------- */
206    
207  void osm_node_free(icon_t **icon, node_t *node) {  void osm_node_free(osm_t *osm, icon_t **icon, node_t *node) {
208      item_id_t id = node->id;
209    
210    if(node->icon_buf)    if(node->icon_buf)
211      icon_free(icon, node->icon_buf);      icon_free(icon, node->icon_buf);
212    
# Line 212  void osm_node_free(icon_t **icon, node_t Line 214  void osm_node_free(icon_t **icon, node_t
214    g_assert(!node->map_item_chain);    g_assert(!node->map_item_chain);
215    
216    osm_tags_free(node->tag);    osm_tags_free(node->tag);
217    
218    g_free(node);    g_free(node);
219    
220      /* also remove node from hash table */
221      if(osm && id > 0 && osm->node_hash) {
222        // use hash table if present
223        hash_item_t **item = &(osm->node_hash->hash[ID2HASH(id)]);
224        while(*item) {
225          if((*item)->data.node->id == id) {
226            hash_item_t *cur = *item;
227            *item = (*item)->next;
228            g_free(cur);
229            return;
230          }
231    
232          item = &(*item)->next;
233        }
234      }
235  }  }
236    
237  static void osm_nodes_free(icon_t **icon, node_t *node) {  static void osm_nodes_free(osm_t *osm, icon_t **icon, node_t *node) {
238    while(node) {    while(node) {
239      node_t *next = node->next;      node_t *next = node->next;
240      osm_node_free(icon, node);      osm_node_free(osm, icon, node);
241      node = next;      node = next;
242    }    }
243  }  }
# Line 530  void osm_free(icon_t **icon, osm_t *osm) Line 549  void osm_free(icon_t **icon, osm_t *osm)
549    if(osm->bounds)   osm_bounds_free(osm->bounds);    if(osm->bounds)   osm_bounds_free(osm->bounds);
550    if(osm->user)     osm_users_free(osm->user);    if(osm->user)     osm_users_free(osm->user);
551    if(osm->way)      osm_ways_free(osm->way);    if(osm->way)      osm_ways_free(osm->way);
552    if(osm->node)     osm_nodes_free(icon, osm->node);    if(osm->node)     osm_nodes_free(osm, icon, osm->node);
553    if(osm->relation) osm_relations_free(osm->relation);    if(osm->relation) osm_relations_free(osm->relation);
554    g_free(osm);    g_free(osm);
555  }  }
# Line 1615  void osm_way_restore(osm_t *osm, way_t * Line 1634  void osm_way_restore(osm_t *osm, way_t *
1634    while(chain) {    while(chain) {
1635      printf("Node "ITEM_ID_FORMAT" is member\n", chain->id);      printf("Node "ITEM_ID_FORMAT" is member\n", chain->id);
1636      chain->node = osm_get_node_by_id(osm, chain->id);      chain->node = osm_get_node_by_id(osm, chain->id);
1637        chain->node->ways++;
1638    
1639      printf("   -> %p\n", chain->node);      printf("   -> %p\n", chain->node);
1640    
1641      chain = chain->next;      chain = chain->next;
# Line 1682  way_chain_t *osm_node_delete(osm_t *osm, Line 1703  way_chain_t *osm_node_delete(osm_t *osm,
1703          found++;          found++;
1704          *cnode = (*cnode)->next;          *cnode = (*cnode)->next;
1705    
1706          osm_node_free(icon, node);          osm_node_free(osm, icon, node);
1707        } else        } else
1708          cnode = &((*cnode)->next);          cnode = &((*cnode)->next);
1709      }      }

Legend:
Removed from v.237  
changed lines
  Added in v.238