/* * raptor_abbrev_node_lookup: * @nodes: Sequence of nodes to search * @node_type: Raptor identifier type * @node_value: Node value to search with (using raptor_abbrev_node_matches). * @datatype: Literal datatype or NULL * @language: Literal language or NULL * * Return value: non-zero if @node matches the node described by the rest of * the parameters or NULL on failure. */ raptor_abbrev_node* raptor_abbrev_node_lookup(raptor_avltree* nodes, raptor_identifier_type node_type, const void *node_value, raptor_uri *datatype, const unsigned char *language) { raptor_abbrev_node *lookup_node; raptor_abbrev_node *rv_node; /* Create a temporary node for search comparison. */ lookup_node = raptor_new_abbrev_node(node_type, node_value, datatype, language); if(!lookup_node) return NULL; rv_node=(raptor_abbrev_node*)raptor_avltree_search(nodes, lookup_node); /* If not found, insert/return a new one */ if(!rv_node) { if(raptor_avltree_add(nodes, lookup_node)) { /* Insert failed */ raptor_free_abbrev_node(lookup_node); return NULL; } else { return lookup_node; } /* Found */ } else { raptor_free_abbrev_node(lookup_node); return rv_node; } }
static void raptor_free_abbrev_po(raptor_abbrev_node** nodes) { if(nodes[0]) raptor_free_abbrev_node(nodes[0]); if(nodes[1]) raptor_free_abbrev_node(nodes[1]); RAPTOR_FREE(raptor_abbrev_nodes, nodes); }
static void raptor_free_abbrev_po(raptor_abbrev_node** nodes) { RAPTOR_ASSERT_OBJECT_POINTER_RETURN(nodes, raptor_abbrev_node_pair); if(nodes[0]) raptor_free_abbrev_node(nodes[0]); if(nodes[1]) raptor_free_abbrev_node(nodes[1]); RAPTOR_FREE(raptor_abbrev_nodes, nodes); }
void raptor_free_abbrev_subject(raptor_abbrev_subject* subject) { RAPTOR_ASSERT_OBJECT_POINTER_RETURN(subject, raptor_abbrev_subject); if(subject->node) raptor_free_abbrev_node(subject->node); if(subject->node_type) raptor_free_abbrev_node(subject->node_type); if(subject->properties) raptor_free_avltree(subject->properties); if(subject->list_items) raptor_free_sequence(subject->list_items); RAPTOR_FREE(raptor_subject, subject); }
void raptor_free_abbrev_subject(raptor_abbrev_subject* subject) { if(subject) { if(subject->node) raptor_free_abbrev_node(subject->node); if(subject->node_type) raptor_free_abbrev_node(subject->node_type); if(subject->properties) raptor_free_avltree(subject->properties); if(subject->list_items) raptor_free_sequence(subject->list_items); RAPTOR_FREE(raptor_subject, subject); } }
/* destroy a serializer */ static void raptor_turtle_serialize_terminate(raptor_serializer* serializer) { raptor_turtle_context* context=(raptor_turtle_context*)serializer->context; if(context->turtle_writer) { raptor_free_turtle_writer(context->turtle_writer); context->turtle_writer=NULL; } if(context->rdf_nspace) { raptor_free_namespace(context->rdf_nspace); context->rdf_nspace=NULL; } if(context->namespaces) { int i; /* Note: item 0 in the list is rdf:RDF's namespace and freed above */ for(i=1; i< raptor_sequence_size(context->namespaces); i++) { raptor_namespace* ns; ns =(raptor_namespace*)raptor_sequence_get_at(context->namespaces, i); if(ns) raptor_free_namespace(ns); } raptor_free_sequence(context->namespaces); context->namespaces=NULL; } if(context->subjects) { raptor_free_avltree(context->subjects); context->subjects=NULL; } if(context->blanks) { raptor_free_avltree(context->blanks); context->blanks=NULL; } if(context->nodes) { raptor_free_avltree(context->nodes); context->nodes=NULL; } if(context->nstack) { raptor_free_namespaces(context->nstack); context->nstack=NULL; } if(context->rdf_type) { raptor_free_abbrev_node(context->rdf_type); context->rdf_type=NULL; } if(context->rdf_xml_literal_uri) { raptor_free_uri_v2(serializer->world, context->rdf_xml_literal_uri); context->rdf_xml_literal_uri=NULL; } if(context->rdf_first_uri) { raptor_free_uri_v2(serializer->world, context->rdf_first_uri); context->rdf_first_uri=NULL; } if(context->rdf_rest_uri) { raptor_free_uri_v2(serializer->world, context->rdf_rest_uri); context->rdf_rest_uri=NULL; } if(context->rdf_nil_uri) { raptor_free_uri_v2(serializer->world, context->rdf_nil_uri); context->rdf_nil_uri=NULL; } }