Diff of /trunk/src/osm.c

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

revision 72 by harbaum, Wed Feb 11 19:43:03 2009 UTC revision 73 by harbaum, Thu Feb 12 14:27:52 2009 UTC
# Line 578  void osm_members_free(member_t *member) Line 578  void osm_members_free(member_t *member)
578    }    }
579  }  }
580    
581    void osm_relation_free(relation_t *relation) {
582      osm_tags_free(relation->tag);
583      osm_members_free(relation->member);
584    
585      g_free(relation);
586    }
587    
588  static void osm_relations_free(relation_t *relation) {  static void osm_relations_free(relation_t *relation) {
589    while(relation) {    while(relation) {
590      relation_t *next = relation->next;      relation_t *next = relation->next;
591        osm_relation_free(relation);
     osm_tags_free(relation->tag);  
     osm_members_free(relation->member);  
   
     g_free(relation);  
592      relation = next;      relation = next;
593    }    }
594  }  }
# Line 2154  item_id_t osm_new_node_id(osm_t *osm) { Line 2157  item_id_t osm_new_node_id(osm_t *osm) {
2157    return 0;    return 0;
2158  }  }
2159    
2160    item_id_t osm_new_relation_id(osm_t *osm) {
2161      item_id_t id = -1;
2162    
2163      while(TRUE) {
2164        gboolean found = FALSE;
2165        relation_t *relation = osm->relation;
2166        while(relation) {
2167          if(relation->id == id)
2168            found = TRUE;
2169    
2170          relation = relation->next;
2171        }
2172    
2173        /* no such id so far -> use it */
2174        if(!found) return id;
2175    
2176        id--;
2177      }
2178      g_assert(0);
2179      return 0;
2180    }
2181    
2182  node_t *osm_node_new(osm_t *osm, gint x, gint y) {  node_t *osm_node_new(osm_t *osm, gint x, gint y) {
2183    printf("Creating new node\n");    printf("Creating new node\n");
2184    
# Line 2475  void osm_way_remove_from_relation(osm_t Line 2500  void osm_way_remove_from_relation(osm_t
2500    }    }
2501  }  }
2502    
2503    relation_t *osm_relation_new(void) {
2504      printf("Creating new relation\n");
2505    
2506      relation_t *relation = g_new0(relation_t, 1);
2507      relation->visible = TRUE;
2508      relation->flags = OSM_FLAG_NEW;
2509      relation->time = time(NULL);
2510    
2511      /* add created_by tag */
2512      relation->tag = g_new0(tag_t, 1);
2513      relation->tag->key = g_strdup("created_by");
2514      relation->tag->value = g_strdup(PACKAGE " v" VERSION);
2515    
2516      return relation;
2517    }
2518    
2519    void osm_relation_attach(osm_t *osm, relation_t *relation) {
2520      printf("Attaching relation\n");
2521    
2522      relation->id = osm_new_relation_id(osm);
2523      relation->flags = OSM_FLAG_NEW;
2524    
2525      /* attach to end of relation list */
2526      relation_t **lrelation = &osm->relation;
2527      while(*lrelation) lrelation = &(*lrelation)->next;
2528      *lrelation = relation;
2529    }
2530    
2531    
2532  void osm_way_delete(osm_t *osm, icon_t **icon,  void osm_way_delete(osm_t *osm, icon_t **icon,
2533                      way_t *way, gboolean permanently) {                      way_t *way, gboolean permanently) {
2534    

Legend:
Removed from v.72  
changed lines
  Added in v.73