コード例 #1
0
void TNSCollection::free( void *item )
{
    remove( item );
    freeItem( item );
}
コード例 #2
0
void TNSCollection::freeAll()
{
    for( ccIndex i =  0; i < count; i++ )
        freeItem( at(i) );
    count = 0;
}
コード例 #3
0
ファイル: output-gazetteer.c プロジェクト: umidev/osm2pgsql
static int split_tags(struct keyval *tags, unsigned int flags, struct keyval *names, struct keyval *places, 
   int* admin_level, char ** housenumber, char ** street, char ** isin, char ** postcode, char ** countrycode)
{
   int area = 0;
   int placehouse = 0;
   struct keyval *item;

   *admin_level = ADMINLEVEL_NONE;
   *housenumber = 0;
   *street = 0;
   *isin = 0;
   int isinsize = 0;
   *postcode = 0;
   *countrycode = 0;

   /* Initialise the result lists */
   initList(names);
   initList(places);

   /* Loop over the tags */
   while ((item = popItem(tags)) != NULL)
   {
//      fprintf(stderr, "%s\n", item->key);

      /* If this is a name tag, add it to the name list */
      if (strcmp(item->key, "ref") == 0 ||
          strcmp(item->key, "iata") == 0 ||
          strcmp(item->key, "icao") == 0 ||
          strcmp(item->key, "pcode:1") == 0 ||
          strcmp(item->key, "pcode:2") == 0 ||
          strcmp(item->key, "pcode:3") == 0 ||
          strcmp(item->key, "un:pcode:1") == 0 ||
          strcmp(item->key, "un:pcode:2") == 0 ||
          strcmp(item->key, "un:pcode:3") == 0 ||
          strcmp(item->key, "name") == 0 ||
          (strncmp(item->key, "name:", 5) == 0) ||
          strcmp(item->key, "int_name") == 0 ||
          (strncmp(item->key, "int_name:", 9) == 0) || 
          strcmp(item->key, "nat_name") == 0 ||
          (strncmp(item->key, "nat_name:", 9) == 0) || 
          strcmp(item->key, "reg_name") == 0 ||
          (strncmp(item->key, "reg_name:", 9) == 0) || 
          strcmp(item->key, "loc_name") == 0 ||
          (strncmp(item->key, "loc_name:", 9) == 0) || 
          strcmp(item->key, "old_name") == 0 ||
          (strncmp(item->key, "old_name:", 9) == 0) || 
          strcmp(item->key, "alt_name") == 0 ||
          (strncmp(item->key, "alt_name:", 9) == 0) || 
          strcmp(item->key, "official_name") == 0 ||
          (strncmp(item->key, "official_name:", 14) == 0) || 
          strcmp(item->key, "commonname") == 0 ||
          (strncmp(item->key, "commonname:", 11) == 0) ||
          strcmp(item->key, "common_name") == 0 ||
          (strncmp(item->key, "common_name:", 12) == 0) ||
          strcmp(item->key, "place_name") == 0 ||
          (strncmp(item->key, "place_name:", 11) == 0) ||
          strcmp(item->key, "short_name") == 0 ||
          (strncmp(item->key, "short_name:", 11) == 0))
      {
         pushItem(names, item);
      }
      else if (strcmp(item->key, "addr:housename") == 0)
      {
         pushItem(names, item);
         placehouse = 1;
      }
      else if (strcmp(item->key, "postal_code") == 0 ||
          strcmp(item->key, "post_code") == 0 ||
          strcmp(item->key, "postcode") == 0 ||
          strcmp(item->key, "addr:postcode") == 0)
      {
         *postcode = item->value;
         addItem(places, "place", "postcode", 1);
      }
      else if (strcmp(item->key, "addr:street") == 0)
      {
         *street = item->value;
      }
      else if ((strcmp(item->key, "country_code_iso3166_1_alpha_2") == 0 || 
                strcmp(item->key, "country_code_iso3166_1") == 0 || 
                strcmp(item->key, "country_code_iso3166") == 0 || 
                strcmp(item->key, "country_code") == 0 || 
                strcmp(item->key, "iso3166-1") == 0 || 
                strcmp(item->key, "ISO3166-1") == 0 || 
                strcmp(item->key, "iso3166") == 0 || 
                strcmp(item->key, "is_in:country_code") == 0 || 
                strcmp(item->key, "addr:country") == 0 ||
                strcmp(item->key, "addr:country_code") == 0) 
                && strlen(item->value) == 2)
      {
         *countrycode = item->value;
      }
      else if (strcmp(item->key, "addr:housenumber") == 0)
      {
         // house number can be far more complex than just a single house number - leave for postgresql to deal with
         *housenumber = item->value; 
         placehouse = 1;
      }
      else if (strcmp(item->key, "addr:interpolation") == 0)
      {
         // house number can be far more complex than just a single house number - leave for postgresql to deal with
         *housenumber = item->value; 
         addItem(places, "place", "houses", 1);
      }
      else if (strcmp(item->key, "is_in") == 0 ||
          (strncmp(item->key, "is_in:", 5) == 0) ||
          strcmp(item->key, "addr:country")== 0 ||
          strcmp(item->key, "addr:county")== 0 ||
          strcmp(item->key, "addr:city") == 0||
          strcmp(item->key, "addr:state") == 0)
      {
         *isin = realloc(*isin, isinsize + 2 + strlen(item->value));
         *(*isin+isinsize) = ',';
         strcpy(*isin+1+isinsize, item->value);
         isinsize += 1 + strlen(item->value);
      }
      else if (strcmp(item->key, "admin_level") == 0)
      {
         *admin_level = atoi(item->value);
      }
      else
      {
         const struct taginfo *t;

         /* If this is a tag we want then add it to the place list */
         for (t = taginfo; t->name != NULL; t++)
         {
            if ((t->flags & flags) != 0)
            {
               if (strcmp(t->name, item->key) == 0 &&
                   (t->value == NULL || strcmp(t->value, item->value) == 0))
               {
                  if ((t->flags & TAGINFO_AREA) != 0) area = 1;

                  pushItem(places, item);

                  break;
               }
            }
         }

         /* Free the tag if we didn't want it */
         if (t->name == NULL) freeItem(item);
      }
   }

   if (placehouse)
   {
      addItem(places, "place", "house", 1);
   }

   return area;
}