Ejemplo n.º 1
0
/**
 * raptor_free_memory:
 * @ptr: memory pointer
 *
 * Free memory allocated inside raptor.
 * 
 * Some systems require memory allocated in a library to
 * be deallocated in that library.  This function allows
 * memory allocated by raptor to be freed.
 *
 * Examples include the result of the '_to_' methods that returns
 * allocated memory such as raptor_uri_filename_to_uri_string,
 * raptor_uri_filename_to_uri_string
 * and raptor_uri_uri_string_to_filename_fragment
 *
 **/
void
raptor_free_memory(void *ptr)
{
  RAPTOR_ASSERT_OBJECT_POINTER_RETURN(ptr, memory);
  
  RAPTOR_FREE(void, ptr);
}
Ejemplo n.º 2
0
static void
raptor_free_serializer_factory(raptor_serializer_factory* factory)
{
  RAPTOR_ASSERT_OBJECT_POINTER_RETURN(factory, raptor_serializer_factory);

  if(factory->finish_factory)
    factory->finish_factory(factory);
  
  RAPTOR_FREE(raptor_serializer_factory, factory);
}
Ejemplo n.º 3
0
/**
 * raptor_sequence_sort:
 * @seq: sequence to sort
 * @compare: comparison function
 * 
 * The comparison function is compatible with that used for qsort()
 * and provides the addresses of pointers to the data that
 * must be dereferenced to get to the stored sequence data.
 * 
 **/
RAPTOR_EXTERN_C
void
raptor_sequence_sort(raptor_sequence* seq, 
                     int(*compare)(const void *, const void *))
{
  RAPTOR_ASSERT_OBJECT_POINTER_RETURN(seq, raptor_sequence);

  if(seq->size > 1)
    qsort(&seq->sequence[seq->start], seq->size, sizeof(void*), compare);
}
Ejemplo n.º 4
0
/**
 * raptor_uri_set_handler:
 * @handler: URI handler structure
 * @context: URI handler context
 * 
 * Change the URI class implementation to the functions provided by the
 *
 * The URI interface in @handler->initialised should be either 1
 * or 2 (if raptor_uri_compare_func is implemented).
 **/
void
raptor_uri_set_handler(const raptor_uri_handler *handler, void *context) 
{
  RAPTOR_ASSERT_OBJECT_POINTER_RETURN(handler, raptor_uri_handler);
  /* RAPTOR_ASSERT is the negative of ordinary asserts - it fails if the condition is true */
  RAPTOR_ASSERT(!(handler->initialised >= 1 && handler->initialised <= 2),
    "raptor_uri_handler->initialised not 1..2");

  raptor_uri_current_uri_handler=handler;
  raptor_uri_current_uri_context=context;
}
Ejemplo n.º 5
0
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);
}
Ejemplo n.º 6
0
/**
 * raptor_free_id_set:
 * @set: #raptor_id_set
 *
 * INTERNAL - Destructor - Free ID Set.
 *
 **/
void
raptor_free_id_set(raptor_id_set *set) 
{
  raptor_base_id_set *base;

  RAPTOR_ASSERT_OBJECT_POINTER_RETURN(set, raptor_id_set);

  base = set->first;
  while(base) {
    raptor_base_id_set *next = base->next;
    raptor_free_base_id_set(base);
    base = next;
  }
  RAPTOR_FREE(raptor_id_set, set);
}
Ejemplo n.º 7
0
/**
 * raptor_free_iostream:
 * @iostr: iostream object
 *
 * Destructor - destroy an iostream.
 **/
void
raptor_free_iostream(raptor_iostream *iostr)
{
  RAPTOR_ASSERT_OBJECT_POINTER_RETURN(iostr, raptor_iostream);
  
  if(iostr->flags & RAPTOR_IOSTREAM_FLAGS_EOF)
    raptor_iostream_write_end(iostr);

  if(iostr->handler->finish)
    iostr->handler->finish(iostr->user_data);

  if((iostr->flags & RAPTOR_IOSTREAM_FLAGS_FREE_HANDLER))
    RAPTOR_FREE(raptor_iostream_handler2, iostr->handler);

  RAPTOR_FREE(raptor_iostream, iostr);
}
Ejemplo n.º 8
0
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);
}
Ejemplo n.º 9
0
/**
 * raptor_sequence_print:
 * @seq: sequence to sort
 * @fh: file handle
 *
 * Print the sequence contents using the print_handler to print the data items.
 */
void
raptor_sequence_print(raptor_sequence* seq, FILE* fh)
{
  int i;

  RAPTOR_ASSERT_OBJECT_POINTER_RETURN(seq, raptor_sequence);

  fputc('[', fh);
  for(i=0; i<seq->size; i++) {
    if(i)
      fputs(", ", fh);
    if(seq->sequence[seq->start+i]) {
      if(seq->print_handler)
        seq->print_handler(seq->sequence[seq->start+i], fh);
      else if(seq->print_handler_v2)
        seq->print_handler_v2(seq->handler_context, seq->sequence[seq->start+i], fh);
    } else
      fputs("(empty)", fh);
  }
  fputc(']', fh);
}
Ejemplo n.º 10
0
/**
 * raptor_free_sax2:
 * @sax2: SAX2 object
 *
 * Destructor - destroy a SAX2 object
 */
void
raptor_free_sax2(raptor_sax2 *sax2)
{
  raptor_xml_element *xml_element;

  RAPTOR_ASSERT_OBJECT_POINTER_RETURN(sax2, raptor_sax2);

#ifdef RAPTOR_XML_EXPAT
  if(sax2->xp) {
    XML_ParserFree(sax2->xp);
    sax2->xp=NULL;
  }
#endif

#ifdef RAPTOR_XML_LIBXML
  if(sax2->xc) {
    raptor_libxml_free(sax2->xc);
    sax2->xc=NULL;
  }

  if(sax2->world->libxml_flags & RAPTOR_LIBXML_FLAGS_STRUCTURED_ERROR_SAVE)
    xmlSetStructuredErrorFunc(sax2->saved_structured_error_context,
                              sax2->saved_structured_error_handler);

  if(sax2->world->libxml_flags & RAPTOR_LIBXML_FLAGS_GENERIC_ERROR_SAVE)
    xmlSetGenericErrorFunc(sax2->saved_generic_error_context,
                           sax2->saved_generic_error_handler);
#endif

  while( (xml_element=raptor_xml_element_pop(sax2)) )
    raptor_free_xml_element(xml_element);

  raptor_namespaces_clear(&sax2->namespaces);

  if(sax2->base_uri)
    raptor_free_uri_v2(sax2->world, sax2->base_uri);

  RAPTOR_FREE(raptor_sax2, sax2);
}
Ejemplo n.º 11
0
void
raptor_free_abbrev_node(raptor_abbrev_node* node)
{
  RAPTOR_ASSERT_OBJECT_POINTER_RETURN(node, raptor_abbrev_node);

  if(--node->ref_count)
    return;
  
  switch (node->type) {
      case RAPTOR_IDENTIFIER_TYPE_RESOURCE:
      case RAPTOR_IDENTIFIER_TYPE_PREDICATE:
        raptor_free_uri(node->value.resource.uri);
        break;
          
      case RAPTOR_IDENTIFIER_TYPE_ANONYMOUS:
        RAPTOR_FREE(blank, node->value.blank.string);
        break;
          
      case RAPTOR_IDENTIFIER_TYPE_LITERAL:
      case RAPTOR_IDENTIFIER_TYPE_XML_LITERAL:
        RAPTOR_FREE(literal, node->value.literal.string);

        if(node->value.literal.datatype)
          raptor_free_uri(node->value.literal.datatype);

        if(node->value.literal.language)
          RAPTOR_FREE(language, node->value.literal.language);

        break;
          
      case RAPTOR_IDENTIFIER_TYPE_ORDINAL:
      case RAPTOR_IDENTIFIER_TYPE_UNKNOWN: 
      default:
        /* Nothing to do */
        break;
  }

  RAPTOR_FREE(raptor_abbrev_node, node);
}
Ejemplo n.º 12
0
/**
 * raptor_free_sequence:
 * @seq: sequence to destroy
 * 
 * Destructor - free a #raptor_sequence
 **/
void
raptor_free_sequence(raptor_sequence* seq)
{
  int i;
  int j;

  RAPTOR_ASSERT_OBJECT_POINTER_RETURN(seq, raptor_sequence);

  if(seq->free_handler) {
    for(i=seq->start, j=seq->start+seq->size; i<j; i++)
      if(seq->sequence[i])
        seq->free_handler(seq->sequence[i]);
  } else if(seq->free_handler_v2) {
    for(i=seq->start, j=seq->start+seq->size; i<j; i++)
      if(seq->sequence[i])
        seq->free_handler_v2(seq->handler_context, seq->sequence[i]);
  }

  if(seq->sequence)
    RAPTOR_FREE(ptrarray, seq->sequence);

  RAPTOR_FREE(raptor_sequence, seq);
}