本文整理汇总了C++中RAPTOR_FREE函数的典型用法代码示例。如果您正苦于以下问题:C++ RAPTOR_FREE函数的具体用法?C++ RAPTOR_FREE怎么用?C++ RAPTOR_FREE使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RAPTOR_FREE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: raptor_rss_common_terminate
void
raptor_rss_common_terminate(raptor_world* world) {
int i;
if(--world->rss_common_initialised)
return;
if(world->rss_types_info_uris) {
for(i = 0; i< RAPTOR_RSS_COMMON_SIZE; i++) {
if(world->rss_types_info_uris[i])
raptor_free_uri(world->rss_types_info_uris[i]);
}
RAPTOR_FREE(raptor_uri* array, world->rss_types_info_uris);
world->rss_types_info_uris = NULL;
}
if(world->rss_fields_info_uris) {
for(i = 0; i< RAPTOR_RSS_FIELDS_SIZE; i++) {
if(world->rss_fields_info_uris[i])
raptor_free_uri(world->rss_fields_info_uris[i]);
}
RAPTOR_FREE(raptor_uri* array, world->rss_fields_info_uris);
world->rss_fields_info_uris = NULL;
}
if(world->rss_namespaces_info_uris) {
for(i = 0; i < RAPTOR_RSS_NAMESPACES_SIZE;i++) {
if(world->rss_namespaces_info_uris[i])
raptor_free_uri(world->rss_namespaces_info_uris[i]);
}
RAPTOR_FREE(raptor_uri* array, world->rss_namespaces_info_uris);
world->rss_namespaces_info_uris = NULL;
}
}
示例2: raptor_new_uri_for_retrieval
/**
* raptor_new_uri_for_retrieval - Turn a URI into one suitable for retrieval
* @old_uri: URI to transform
*
* Takes an existing URI and ensures it has a path (default /) and has
* no fragment - URI retrieval does not use the fragment part.
*
* Return value: new URI object or NULL on failure.
**/
raptor_uri*
raptor_new_uri_for_retrieval(raptor_uri* old_uri)
{
unsigned char *uri_string=raptor_uri_as_string(old_uri);
unsigned char *buffer;
size_t buffer_len=strlen((const char*)uri_string)+1;
unsigned char *scheme;
unsigned char *authority;
unsigned char *path;
unsigned char *query;
unsigned char *fragment;
unsigned char *new_uri_string;
raptor_uri* new_uri;
buffer=(unsigned char*)RAPTOR_MALLOC(cstring, buffer_len);
if(!buffer)
return NULL;
raptor_uri_parse (uri_string, buffer, buffer_len,
&scheme, &authority, &path, &query, &fragment);
if(!path)
path=(unsigned char*)"/";
new_uri_string=raptor_uri_construct(scheme, authority, path, query, NULL);
RAPTOR_FREE(cstring, buffer);
if(!new_uri_string)
return NULL;
new_uri=raptor_new_uri(new_uri_string);
RAPTOR_FREE(cstring, new_uri_string);
return new_uri;
}
示例3: assert_uri_to_filename
static int
assert_uri_to_filename (const char *uri, const char *reference_filename)
{
char *filename;
filename=raptor_uri_uri_string_to_filename((const unsigned char*)uri);
if(filename && !reference_filename) {
fprintf(stderr,
"%s: raptor_uri_uri_string_to_filename(%s) FAILED giving filename %s != NULL\n",
program, uri, filename);
if(filename)
RAPTOR_FREE(cstring, filename);
return 1;
} else if (filename && strcmp(filename, reference_filename)) {
fprintf(stderr,
"%s: raptor_uri_uri_string_to_filename(%s) FAILED gaving filename %s != %s\n",
program, uri, filename, reference_filename);
if(filename)
RAPTOR_FREE(cstring, filename);
return 1;
}
RAPTOR_FREE(cstring, filename);
return 0;
}
示例4: assert_uri_to_relative
static int
assert_uri_to_relative(const char *base, const char *uri, const char *relative)
{
unsigned char *output;
int result;
raptor_uri* base_uri=NULL;
raptor_uri* reference_uri=raptor_new_uri((const unsigned char*)uri);
size_t length=0;
if(base)
base_uri=raptor_new_uri((const unsigned char*)base);
output=raptor_uri_to_relative_counted_uri_string(base_uri, reference_uri,
&length);
result=strcmp(relative, (const char*)output);
if (result) {
fprintf(stderr,
"%s: raptor_uri_string_to_relative_uri_string FAILED: base='%s', uri='%s', expected='%s', got='%s'\n",
program, base, uri, relative, output);
RAPTOR_FREE(cstring, output);
return 1;
}
RAPTOR_FREE(cstring, output);
raptor_free_uri(base_uri);
raptor_free_uri(reference_uri);
return 0;
}
示例5: raptor_print_subject
void
raptor_print_subject(raptor_abbrev_subject* subject)
{
int i;
unsigned char *subj;
unsigned char *pred;
unsigned char *obj;
raptor_avltree_iterator* iter=NULL;
/* Note: The raptor_abbrev_node field passed as the first argument for
* raptor_statement_part_as_string() is somewhat arbitrary, since as
* the data structure is designed, the first word in the value union
* is what was passed as the subject/predicate/object of the
* statement.
*/
subj = raptor_statement_part_as_string(subject->node->value.resource.uri,
subject->node->type, NULL, NULL);
if(subject->type) {
obj=raptor_statement_part_as_string(subject->type->value.resource.uri,
subject->type->type,
subject->type->value.literal.datatype,
subject->type->value.literal.language);
fprintf(stderr,"[%s, http://www.w3.org/1999/02/22-rdf-syntax-ns#type, %s]\n", subj, obj);
RAPTOR_FREE(cstring, obj);
}
for(i=0; i < raptor_sequence_size(subject->elements); i++) {
raptor_abbrev_node* o = raptor_sequence_get_at(subject->elements, i);
if(o) {
obj = raptor_statement_part_as_string(o->value.literal.string,
o->type,
o->value.literal.datatype,
o->value.literal.language);
fprintf(stderr,"[%s, [rdf:_%d], %s]\n", subj, i, obj);
RAPTOR_FREE(cstring, obj);
}
}
iter=raptor_new_avltree_iterator(subject->properties, NULL, NULL, 1);
while(iter) {
raptor_abbrev_node** nodes;
nodes=(raptor_abbrev_node**)raptor_avltree_iterator_get(iter);
if(!nodes)
break;
raptor_print_abbrev_po(stderr, nodes);
if(raptor_avltree_iterator_next(iter))
break;
}
if(iter)
raptor_free_avltree_iterator(iter);
RAPTOR_FREE(cstring, subj);
}
示例6: raptor_rss_field_free
void
raptor_rss_field_free(raptor_rss_field* field)
{
if(field->value)
RAPTOR_FREE(cstring, field->value);
if(field->uri)
raptor_free_uri(field->uri);
if(field->next)
raptor_rss_field_free(field->next);
RAPTOR_FREE(raptor_rss_field, field);
}
示例7: raptor_new_iostream_to_string
/**
* raptor_new_iostream_to_string:
* @string_p: pointer to location to hold string
* @length_p: pointer to location to hold length of string (or NULL)
* @malloc_handler: pointer to malloc to use to make string (or NULL)
*
* Constructor - create a new iostream writing to a string.
*
* If @malloc_handler is null, raptor will allocate it using it's
* own memory allocator. *@string_p is set to NULL on failure (and
* *@length_p to 0 if @length_p is not NULL).
*
* Return value: new #raptor_iostream object or NULL on failure
**/
RAPTOR_EXTERN_C
raptor_iostream*
raptor_new_iostream_to_string(void **string_p, size_t *length_p,
void *(*malloc_handler)(size_t size))
{
raptor_iostream* iostr;
struct raptor_write_string_iostream_context* con;
const raptor_iostream_handler2* handler2=&raptor_iostream_write_string_handler;
const unsigned int mode=RAPTOR_IOSTREAM_MODE_WRITE;
if(!raptor_iostream_check_handler(handler2, mode))
return NULL;
iostr=(raptor_iostream*)RAPTOR_CALLOC(raptor_iostream, 1,
sizeof(raptor_iostream));
if(!iostr)
return NULL;
con=(struct raptor_write_string_iostream_context*)RAPTOR_CALLOC(raptor_write_string_iostream_context, 1, sizeof(struct raptor_write_string_iostream_context));
if(!con) {
RAPTOR_FREE(raptor_iostream, iostr);
return NULL;
}
con->sb=raptor_new_stringbuffer();
if(!con->sb) {
RAPTOR_FREE(raptor_iostream, iostr);
RAPTOR_FREE(raptor_write_string_iostream_context, con);
return NULL;
}
con->string_p=string_p;
*string_p=NULL;
con->length_p=length_p;
if(length_p)
*length_p=0;
if(malloc_handler)
con->malloc_handler=malloc_handler;
else
con->malloc_handler=raptor_alloc_memory;
iostr->handler=handler2;
iostr->user_data=(void*)con;
iostr->mode = mode;
if(iostr->handler->init && iostr->handler->init(iostr->user_data)) {
raptor_free_iostream(iostr);
return NULL;
}
return iostr;
}
示例8: raptor_free_term
/**
* raptor_free_term:
* @term: #raptor_term object
*
* Destructor - destroy a raptor_term object.
*
**/
void
raptor_free_term(raptor_term *term)
{
if(!term)
return;
if(--term->usage)
return;
switch(term->type) {
case RAPTOR_TERM_TYPE_URI:
if(term->value.uri) {
raptor_free_uri(term->value.uri);
term->value.uri = NULL;
}
break;
case RAPTOR_TERM_TYPE_BLANK:
if(term->value.blank.string) {
RAPTOR_FREE(cstring, (void*)term->value.blank.string);
term->value.blank.string = NULL;
}
break;
case RAPTOR_TERM_TYPE_LITERAL:
if(term->value.literal.string) {
RAPTOR_FREE(cstring, (void*)term->value.literal.string);
term->value.literal.string = NULL;
}
if(term->value.literal.datatype) {
raptor_free_uri(term->value.literal.datatype);
term->value.literal.datatype = NULL;
}
if(term->value.literal.language) {
RAPTOR_FREE(cstring, (void*)term->value.literal.language);
term->value.literal.language = NULL;
}
break;
case RAPTOR_TERM_TYPE_UNKNOWN:
default:
break;
}
RAPTOR_FREE(term, (void*)term);
}
示例9: raptor_free_iostream
/**
* 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);
}
示例10: raptor_new_iostream_from_file_handle
/**
* raptor_new_iostream_from_file_handle:
* @handle: Input file_handle to open and read from
*
* Constructor - create a new iostream reading from a file_handle.
*
* The @handle must already be open for reading.
* NOTE: This does not fclose the @handle when it is finished.
*
* Return value: new #raptor_iostream object or NULL on failure
**/
raptor_iostream*
raptor_new_iostream_from_file_handle(FILE *handle)
{
raptor_iostream* iostr;
const raptor_iostream_handler2* handler2=&raptor_iostream_read_file_handle_handler;
const unsigned int mode=RAPTOR_IOSTREAM_MODE_READ;
if(!handle)
return NULL;
if(!raptor_iostream_check_handler(handler2, mode))
return NULL;
iostr=(raptor_iostream*)RAPTOR_CALLOC(raptor_iostream, 1,
sizeof(raptor_iostream));
if(!iostr)
return NULL;
iostr->handler=handler2;
iostr->user_data=(void*)handle;
iostr->mode = mode;
if(iostr->handler->init &&
iostr->handler->init(iostr->user_data)) {
RAPTOR_FREE(raptor_iostream, iostr);
return NULL;
}
return iostr;
}
示例11: raptor_new_iostream_from_handler
/**
* raptor_new_iostream_from_handler:
* @context: pointer to context information to pass in to calls
* @handler: pointer to handler methods
*
* Create a new iostream over a user-defined handler.
*
* @deprecated: Use raptor_new_iostream_from_handler2() instead
*
* Return value: new #raptor_iostream object or NULL on failure
**/
raptor_iostream*
raptor_new_iostream_from_handler(void *user_data,
const raptor_iostream_handler *handler)
{
raptor_iostream* iostr=NULL;
raptor_iostream_handler2 *handler2;
if(!handler)
return NULL;
handler2=(raptor_iostream_handler2*)RAPTOR_CALLOC(raptor_iostream_handler2, 1,
sizeof(raptor_iostream_handler2*));
if(!handler2)
return NULL;
/* Copy V1 functions to V2 structure */
handler2->init = handler->init;
handler2->finish = handler->finish;
handler2->write_byte = handler->write_byte;
handler2->write_bytes = handler->write_bytes;
handler2->write_end = handler->write_end;
iostr=raptor_new_iostream_from_handler2(user_data, handler2);
if(iostr) {
/* Ensure newly alloced structure is freed on iostream destruction */
iostr->flags |= RAPTOR_IOSTREAM_FLAGS_FREE_HANDLER;
} else
/* failure: so delete it now */
RAPTOR_FREE(raptor_iostream_handler2, handler2);
return iostr;
}
示例12: raptor_libxml_validation_warning
void
raptor_libxml_validation_warning(void* user_data, const char *msg, ...)
{
va_list args;
raptor_sax2* sax2 = (raptor_sax2*)user_data;
int prefix_length = strlen(xml_validation_warning_prefix);
int length;
char *nmsg;
size_t msg_len;
va_start(args, msg);
raptor_libxml_update_document_locator(sax2, sax2->locator);
msg_len = strlen(msg);
length = prefix_length + msg_len + 1;
nmsg = (char*)RAPTOR_MALLOC(cstring, length);
if(nmsg) {
memcpy(nmsg, xml_validation_warning_prefix, prefix_length); /* Do not copy NUL */
memcpy(nmsg + prefix_length, msg, msg_len + 1); /* Copy NUL */
if(nmsg[length-2] == '\n')
nmsg[length-2]='\0';
}
raptor_log_error_varargs(sax2->world,
RAPTOR_LOG_LEVEL_WARN,
sax2->locator,
nmsg ? nmsg : msg,
args);
if(nmsg)
RAPTOR_FREE(cstring,nmsg);
va_end(args);
}
示例13: raptor_www_curl_header_callback
static size_t
raptor_www_curl_header_callback(void* ptr, size_t size, size_t nmemb,
void *userdata)
{
raptor_www* www=(raptor_www*)userdata;
int bytes=size*nmemb;
/* If WWW has been aborted, return nothing so that
* libcurl will abort the transfer
*/
if(www->failed)
return 0;
if(!strncmp((char*)ptr, "Content-Type: ", 14)) {
int len=bytes-16;
char *type_buffer=(char*)RAPTOR_MALLOC(cstring, len+1);
strncpy(type_buffer, (char*)ptr+14, len);
type_buffer[len]='\0';
if(www->type)
RAPTOR_FREE(cstring, www->type);
www->type=type_buffer;
www->free_type=1;
#if RAPTOR_DEBUG > 2
RAPTOR_DEBUG3("Got content type '%s' (%d bytes)\n", type_buffer, len);
#endif
if(www->content_type)
www->content_type(www, www->content_type_userdata, www->type);
}
return bytes;
}
示例14: raptor_free_sax2
/**
* raptor_free_sax2:
* @sax2: SAX2 object
*
* Destructor - destroy a SAX2 object
*/
void
raptor_free_sax2(raptor_sax2 *sax2)
{
raptor_xml_element *xml_element;
if(!sax2)
return;
#ifdef RAPTOR_XML_LIBXML
if(sax2->xc) {
raptor_libxml_free(sax2->xc);
sax2->xc = NULL;
}
#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(sax2->base_uri);
raptor_object_options_clear(&sax2->options);
RAPTOR_FREE(raptor_sax2, sax2);
}
示例15: raptor_ntriples_parse_terminate
/*
* raptor_ntriples_parse_terminate - Free the Raptor NTriples parser
* @rdf_parser: parser object
*
**/
static void
raptor_ntriples_parse_terminate(raptor_parser* rdf_parser)
{
raptor_ntriples_parser_context *ntriples_parser=(raptor_ntriples_parser_context*)rdf_parser->context;
if(ntriples_parser->line_length)
RAPTOR_FREE(cdata, ntriples_parser->line);
}