Changeset 2089
- Timestamp:
- 06/03/09 16:45:17 (15 months ago)
- Location:
- trunk/slv2
- Files:
-
- 4 modified
-
src/plugin.c (modified) (9 diffs)
-
src/port.c (modified) (1 diff)
-
src/slv2_internal.h (modified) (1 diff)
-
test/slv2_test.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/slv2/src/plugin.c
r2087 r2089 49 49 plugin->storage = NULL; 50 50 plugin->rdf = NULL; 51 plugin->num_ports = 0; 51 52 52 53 return plugin; … … 67 68 p->binary_uri = NULL; 68 69 69 if (p->ports) 70 raptor_free_sequence(p->ports); 71 p->ports = NULL; 70 if (p->ports) { 71 for (uint32_t i = 0; i < p->num_ports; ++i) 72 slv2_port_free(p->ports[i]); 73 free(p->ports); 74 p->ports = NULL; 75 } 72 76 73 77 if (p->rdf) { … … 123 127 124 128 if (!p->ports) { 125 p->ports = raptor_new_sequence((void (*)(void*))&slv2_port_free, NULL); 129 p->ports = malloc(sizeof(SLV2Port*)); 130 p->ports[0] = NULL; 126 131 127 132 const unsigned char* query = (const unsigned char*) … … 144 149 librdf_node* index_node = librdf_query_results_get_binding_value(results, 2); 145 150 146 if (librdf_node_is_literal(symbol_node) && librdf_node_is_literal(index_node)) {151 if (librdf_node_is_literal(symbol_node) && librdf_node_is_literal(index_node)) { 147 152 const char* symbol = (const char*)librdf_node_get_literal_value(symbol_node); 148 153 const char* index = (const char*)librdf_node_get_literal_value(index_node); 149 154 150 155 const int this_index = atoi(index); 151 SLV2Port this_port = raptor_sequence_get_at(p->ports, this_index); 152 153 // Havn't seen this port yet, add it to sequence 156 SLV2Port this_port = NULL; 157 158 assert(this_index >= 0); 159 160 if (p->num_ports > (unsigned)this_index) { 161 this_port = p->ports[this_index]; 162 } else { 163 p->ports = realloc(p->ports, (this_index + 1) * sizeof(SLV2Port*)); 164 memset(p->ports + p->num_ports, '\0', 165 (this_index - p->num_ports) * sizeof(SLV2Port)); 166 p->num_ports = this_index + 1; 167 } 168 169 // Havn't seen this port yet, add it to array 154 170 if (!this_port) { 155 171 this_port = slv2_port_new(p->world, this_index, symbol); 156 raptor_sequence_set_at(p->ports, this_index, this_port);172 p->ports[this_index] = this_port; 157 173 } 158 174 … … 498 514 { 499 515 slv2_plugin_load_ports_if_necessary(p); 500 return raptor_sequence_size(p->ports);516 return p->num_ports; 501 517 } 502 518 … … 509 525 slv2_plugin_load_ports_if_necessary(p); 510 526 511 for ( int i = 0; i < raptor_sequence_size(p->ports); ++i)527 for (uint32_t i = 0; i < p->num_ports; ++i) 512 528 values[i] = NAN; 513 529 … … 571 587 va_list args; 572 588 573 for (unsigned i=0; i < slv2_plugin_get_num_ports(p); ++i) {574 SLV2Port port = raptor_sequence_get_at(p->ports, i);589 for (unsigned i=0; i < p->num_ports; ++i) { 590 SLV2Port port = p->ports[i]; 575 591 if (!slv2_port_is_a(p, port, class_1)) 576 592 continue; … … 692 708 { 693 709 slv2_plugin_load_ports_if_necessary(p); 694 return raptor_sequence_get_at(p->ports, (int)index); 710 if (index < p->num_ports) 711 return p->ports[index]; 712 else 713 return NULL; 695 714 } 696 715 … … 701 720 { 702 721 slv2_plugin_load_ports_if_necessary(p); 703 for ( int i=0; i < raptor_sequence_size(p->ports); ++i) {704 SLV2Port port = raptor_sequence_get_at(p->ports, i);722 for (uint32_t i=0; i < p->num_ports; ++i) { 723 SLV2Port port = p->ports[i]; 705 724 if (slv2_value_equals(port->symbol, symbol)) 706 725 return port; -
trunk/slv2/src/port.c
r2007 r2089 39 39 port->symbol = slv2_value_new(world, SLV2_VALUE_STRING, symbol); 40 40 port->classes = slv2_values_new(); 41 //port->node_id = strdup(node_id);42 41 return port; 43 42 } -
trunk/slv2/src/slv2_internal.h
r2086 r2089 62 62 SLV2PluginClass plugin_class; 63 63 raptor_sequence* data_uris; ///< rdfs::seeAlso 64 raptor_sequence*ports;64 SLV2Port* ports; 65 65 librdf_storage* storage; 66 66 librdf_model* rdf; 67 uint32_t num_ports; 67 68 }; 68 69 -
trunk/slv2/test/slv2_test.c
r2000 r2089 555 555 PLUGIN_NAME("Test plugin") " ; " 556 556 LICENSE_GPL " ; " 557 "lv2:optionalFeature lv2:hardRtCapable ; "557 "lv2:optionalFeature lv2:hardRtCapable ; " 558 558 "lv2:requiredFeature <http://lv2plug.in/ns/ext/event> ; " 559 559 ":foo 1.6180 ; "
