Changeset 2085

Show
Ignore:
Timestamp:
06/03/09 14:06:07 (15 months ago)
Author:
drobilla
Message:

Fix memory leaks.
Avoid unnecessary URI copy on plugin load.

Location:
trunk/slv2/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/slv2/src/plugin.c

    r2007 r2085  
    209209        for (unsigned i=0; i < slv2_values_size(p->data_uris); ++i) { 
    210210                SLV2Value data_uri_val = slv2_values_get_at(p->data_uris, i); 
    211                 librdf_uri* data_uri = librdf_new_uri(p->world->world, 
    212                                 (const unsigned char*)slv2_value_as_uri(data_uri_val)); 
     211                librdf_uri* data_uri = slv2_value_as_librdf_uri(data_uri_val); 
    213212                librdf_parser_parse_into_model(p->world->parser, data_uri, NULL, p->rdf); 
    214                 librdf_free_uri(data_uri); 
    215213        } 
    216214} 
  • trunk/slv2/src/world.c

    r2083 r2085  
    177177slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri) 
    178178{ 
     179        if (!slv2_value_is_uri(bundle_uri)) { 
     180                fprintf(stderr, "ERROR: slv2_world_load_bundle called with non-URI argument\n"); 
     181                return; 
     182        } 
     183 
    179184        librdf_uri* manifest_uri = librdf_new_uri_relative_to_base( 
    180185                        bundle_uri->val.uri_val, (const unsigned char*)"manifest.ttl"); 
     
    465470                        } 
    466471 
    467                         SLV2Value uri = slv2_value_new_librdf_uri(world, class_uri); 
    468  
    469472                        // If this class differs from the last, append a new one 
    470473                        if (!plugin_class) { 
     
    492495                                        // Otherwise the query engine is giving us unsorted results :/ 
    493496                                        } else { 
     497                                                SLV2Value uri = slv2_value_new_librdf_uri(world, class_uri); 
    494498                                                plugin_class = slv2_plugin_classes_get_by_uri(classes, uri); 
    495499                                                if (!plugin_class) { 
     
    498502                                                        raptor_sequence_sort(classes, slv2_plugin_class_compare_by_uri); 
    499503                                                } 
     504                                                slv2_value_free(uri); 
    500505                                        } 
    501506                                } 
     
    588593                        } 
    589594 
    590                         SLV2Value uri = slv2_value_new_librdf_uri(world, plugin_uri); 
    591  
    592595                        // If this plugin differs from the last, append a new one 
    593596                        if (!plugin) { 
     597                                SLV2Value uri = slv2_value_new_librdf_uri(world, plugin_uri); 
    594598                                if (n_plugins == 0) { 
    595599                                        plugin = slv2_plugin_new(world, uri, bundle_uri); 
     
    620624                                                        raptor_sequence_push(world->plugins, plugin); 
    621625                                                        raptor_sequence_sort(world->plugins, slv2_plugin_compare_by_uri); 
     626                                                } else { 
     627                                                        slv2_value_free(uri); 
    622628                                                } 
    623629                                        }