/** * librdf_hash_bdb_delete_key - Delete all values for given key from the hash * @context: BerkeleyDB hash context * @key: key * * Return value: non 0 on failure **/ static int librdf_hash_bdb_delete_key(void* context, librdf_hash_datum *key) { librdf_hash_bdb_context* bdb_context=(librdf_hash_bdb_context*)context; DB* bdb=bdb_context->db; DBT bdb_key; int ret; memset(&bdb_key, 0, sizeof(DBT)); /* Initialise BDB version of key */ bdb_key.data = (char*)key->data; bdb_key.size = key->size; #ifdef HAVE_BDB_DB_TXN /* V2/V3 */ ret=bdb->del(bdb, NULL, &bdb_key, 0); #else /* V1 */ ret=bdb->del(bdb, &bdb_key, 0); #endif if(ret) LIBRDF_DEBUG2("BDB del failed - %d\n", ret); return (ret != 0); }
static librdf_node* rasqal_literal_to_redland_node(librdf_world *world, rasqal_literal* l) { rasqal_literal_type type; if(!l) return NULL; /* FIXME: Workaround for Issue #0000519 * http://bugs.librdf.org/mantis/view.php?id=519 * * Remove this 'if' when RASQAL_MIN_VERSION is 0.9.30 or larger */ if(l->type == RASQAL_LITERAL_INTEGER_SUBTYPE) type = RASQAL_LITERAL_STRING; else type = rasqal_literal_get_rdf_term_type(l); if(type == RASQAL_LITERAL_URI) return librdf_new_node_from_uri(world, (librdf_uri*)l->value.uri); else if (type == RASQAL_LITERAL_STRING) return librdf_new_node_from_typed_literal(world, (unsigned char*)l->string, l->language, (librdf_uri*)l->datatype); else if (type == RASQAL_LITERAL_BLANK) return librdf_new_node_from_blank_identifier(world, (unsigned char*)l->string); LIBRDF_DEBUG2("Could not convert literal type %d to librdf_node\n", type); return NULL; }
/** * librdf_get_storage_factory - Get a storage factory by name * @name: the factory name or NULL for the default factory * * Return value: the factory object or NULL if there is no such factory **/ librdf_storage_factory* librdf_get_storage_factory (const char *name) { librdf_storage_factory *factory; /* return 1st storage if no particular one wanted - why? */ if(!name) { factory=storages; if(!factory) { LIBRDF_DEBUG1("No (default) storages registered\n"); return NULL; } } else { for(factory=storages; factory; factory=factory->next) { if(!strcmp(factory->name, name)) { break; } } /* else FACTORY name not found */ if(!factory) { LIBRDF_DEBUG2("No storage with name %s found\n", name); return NULL; } } return factory; }
/** * librdf_storage_register_factory - Register a storage factory * @name: the storage factory name * @label: the storage factory label * @factory: pointer to function to call to register the factory * **/ void librdf_storage_register_factory(const char *name, const char *label, void (*factory) (librdf_storage_factory*)) { librdf_storage_factory *storage, *h; char *name_copy; char *label_copy; #if defined(LIBRDF_DEBUG) && LIBRDF_DEBUG > 1 LIBRDF_DEBUG2("Received registration for storage %s\n", name); #endif storage=(librdf_storage_factory*)LIBRDF_CALLOC(librdf_storage_factory, 1, sizeof(librdf_storage_factory)); if(!storage) LIBRDF_FATAL1(world, "Out of memory"); name_copy=(char*)LIBRDF_CALLOC(cstring, strlen(name)+1, 1); if(!name_copy) { LIBRDF_FREE(librdf_storage, storage); LIBRDF_FATAL1(world, "Out of memory"); } strcpy(name_copy, name); storage->name=name_copy; for(h = storages; h; h = h->next ) { if(!strcmp(h->name, name_copy)) { LIBRDF_FREE(cstring, name_copy); LIBRDF_FREE(librdf_storage, storage); LIBRDF_ERROR2(NULL, "storage %s already registered\n", h->name); return; } } label_copy=(char*)LIBRDF_CALLOC(cstring, strlen(label)+1, 1); if(!label_copy) { LIBRDF_FREE(librdf_storage, storage); LIBRDF_FATAL1(world, "Out of memory"); } strcpy(label_copy, label); storage->label=label_copy; /* Call the storage registration function on the new object */ (*factory)(storage); #if defined(LIBRDF_DEBUG) && LIBRDF_DEBUG > 1 LIBRDF_DEBUG3("%s has context size %d\n", name, storage->context_length); #endif storage->next = storages; storages = storage; }
/** * librdf_hash_bdb_put - Store a key/value pair in the hash * @context: BerkeleyDB hash context * @key: pointer to key to store * @value: pointer to value to store * * Return value: non 0 on failure **/ static int librdf_hash_bdb_put(void* context, librdf_hash_datum *key, librdf_hash_datum *value) { librdf_hash_bdb_context* bdb_context=(librdf_hash_bdb_context*)context; DB* db=bdb_context->db; DBT bdb_value; DBT bdb_key; int ret; /* docs say you must zero DBT's before use */ memset(&bdb_value, 0, sizeof(DBT)); memset(&bdb_key, 0, sizeof(DBT)); /* Initialise BDB version of key */ bdb_key.data = (char*)key->data; bdb_key.size = key->size; /* Initialise BDB version of data */ bdb_value.data = (char*)value->data; bdb_value.size = value->size; #ifdef HAVE_BDB_DB_TXN /* V2/V3 prototype: * int DB->put(DB *db, DB_TXN *txnid, DBT *key, DBT *data, u_int32_t flags); */ ret=db->put(db, NULL, &bdb_key, &bdb_value, 0); #else /* V1 */ ret=db->put(db, &bdb_key, &bdb_value, 0); #endif if(ret) LIBRDF_DEBUG2("BDB put failed - %d\n", ret); return (ret != 0); }
/** * librdf_statement_decode2: * @world: redland world * @statement: the statement to deserialise into * @context_node: pointer to #librdf_node context_node to deserialise into * @buffer: the buffer to use * @length: buffer size * * Decodes a statement + context node from a buffer. * * Decodes the serialised statement (as created by librdf_statement_encode() ) * from the given buffer. If a context node is found and context_node is * not NULL, a pointer to the new #librdf_node is stored in *context_node. * * Return value: number of bytes used or 0 on failure (bad encoding, allocation failure) **/ size_t librdf_statement_decode2(librdf_world* world, librdf_statement* statement, librdf_node** context_node, unsigned char *buffer, size_t length) { unsigned char *p; librdf_node* node; unsigned char type; size_t total_length=0; LIBRDF_ASSERT_OBJECT_POINTER_RETURN_VALUE(statement, librdf_statement, 0); #if defined(LIBRDF_DEBUG) && LIBRDF_DEBUG > 1 LIBRDF_DEBUG2("Decoding buffer of %d bytes\n", length); #endif /* absolute minimum - first byte is type */ if(length < 1) return 0; p=buffer; if(*p++ != 'x') return 0; length--; total_length++; while(length>0) { size_t node_len; type=*p++; length--; total_length++; if(!length) return 0; if(!(node=librdf_node_decode(world, &node_len, p, length))) return 0; p += node_len; length -= node_len; total_length += node_len; #if defined(LIBRDF_DEBUG) && LIBRDF_DEBUG > 1 LIBRDF_DEBUG3("Found type %c (%d bytes)\n", type, node_len); #endif switch(type) { case 's': /* subject */ statement->subject=node; break; case 'p': /* predicate */ statement->predicate=node; break; case 'o': /* object */ statement->object=node; break; case 'c': /* context */ if(context_node) *context_node=node; else librdf_free_node(node); break; default: librdf_log(world, 0, LIBRDF_LOG_ERROR, LIBRDF_FROM_STATEMENT, NULL, "Illegal statement encoding '%c' seen", p[-1]); return 0; } } return total_length; }
/** * librdf_new_uri2: * @world: redland world object * @uri_string: URI in string form * @length: length of string * * Constructor - create a new #librdf_uri object from a counted URI string. * * A new URI is constructed from a copy of the string. If the string * is a NULL pointer or 0 length or empty (first byte is 0) then the * result is NULL. * * Return value: a new #librdf_uri object or NULL on failure **/ librdf_uri* librdf_new_uri2(librdf_world *world, const unsigned char *uri_string, size_t length) { #ifdef LIBRDF_USE_RAPTOR_URI return raptor_new_uri_from_counted_string(world->raptor_world_ptr, uri_string, length); #else librdf_uri* new_uri; unsigned char *new_string; librdf_hash_datum key, value; /* on stack - not allocated */ librdf_hash_datum *old_value; /* just to be safe */ memset(&key, 0, sizeof(key)); memset(&value, 0, sizeof(value)); librdf_world_open(world); if(!uri_string || !length || !*uri_string) return NULL; #ifdef WITH_THREADS pthread_mutex_lock(world->mutex); #endif key.data = (char*)uri_string; key.size = length; /* if existing URI found in hash, return it */ if((old_value = librdf_hash_get_one(world->uris_hash, &key))) { new_uri = *(librdf_uri**)old_value->data; #if defined(LIBRDF_DEBUG) && LIBRDF_DEBUG > 1 LIBRDF_DEBUG3("Found existing URI %s in hash with current usage %d\n", uri_string, new_uri->usage); #endif librdf_free_hash_datum(old_value); new_uri->usage++; #if defined(LIBRDF_DEBUG) && LIBRDF_DEBUG > 1 if(new_uri->usage > new_uri->max_usage) new_uri->max_usage = new_uri->usage; #endif goto unlock; } /* otherwise create a new one */ #if defined(LIBRDF_DEBUG) && LIBRDF_DEBUG > 1 LIBRDF_DEBUG2("Creating new URI %s in hash\n", uri_string); #endif new_uri = (librdf_uri*)LIBRDF_CALLOC(librdf_uri, 1, sizeof(librdf_uri)); if(!new_uri) goto unlock; new_uri->world = world; new_uri->string_length = length; new_string = (unsigned char*)LIBRDF_MALLOC(cstring, length+1); if(!new_string) { LIBRDF_FREE(librdf_uri, new_uri); new_uri = NULL; goto unlock; } strcpy((char*)new_string, (const char*)uri_string); new_uri->string = new_string; new_uri->usage = 1; #if defined(LIBRDF_DEBUG) && LIBRDF_DEBUG > 1 new_uri->max_usage = 1; #endif value.data = &new_uri; value.size = sizeof(librdf_uri*); /* store in hash: URI-string => (librdf_uri*) */ if(librdf_hash_put(world->uris_hash, &key, &value)) { LIBRDF_FREE(cstring, new_string); LIBRDF_FREE(librdf_uri, new_uri); new_uri = NULL; } unlock: #ifdef WITH_THREADS pthread_mutex_unlock(world->mutex); #endif return new_uri; #endif /* !LIBRDF_USE_RAPTOR_URI */ }
/** * librdf_hash_bdb_delete_key_value - Delete given key/value from the hash * @context: BerkeleyDB hash context * @key: key * @value: value * * Return value: non 0 on failure **/ static int librdf_hash_bdb_delete_key_value(void* context, librdf_hash_datum *key, librdf_hash_datum *value) { librdf_hash_bdb_context* bdb_context=(librdf_hash_bdb_context*)context; DB* bdb=bdb_context->db; DBT bdb_key, bdb_value; int ret; #ifdef HAVE_BDB_CURSOR DBC* dbc; #endif memset(&bdb_key, 0, sizeof(DBT)); memset(&bdb_value, 0, sizeof(DBT)); /* Initialise BDB version of key */ bdb_key.data = (char*)key->data; bdb_key.size = key->size; bdb_value.data = (char*)value->data; bdb_value.size = value->size; #ifdef HAVE_BDB_CURSOR #ifdef HAVE_BDB_CURSOR_4_ARGS /* V3 prototype: * int DB->cursor(DB *db, DB_TXN *txnid, DBC **cursorp, u_int32_t flags); */ if(bdb->cursor(bdb, NULL, &dbc, 0)) return 1; #else /* V2 prototype: * int DB->cursor(DB *db, DB_TXN *txnid, DBC **cursorp); */ if(bdb->cursor(bdb, NULL, &dbc)) return 1; #endif /* V2/V3 prototype: * int DBcursor->c_get(DBC *cursor, DBT *key, DBT *data, u_int32_t flags); */ #ifdef DB_GET_BOTH /* later V2 (sigh) / V3 */ ret=dbc->c_get(dbc, &bdb_key, &bdb_value, DB_GET_BOTH); #else /* earlier V2 probably gives a memory leak */ ret=dbc->c_get(dbc, &bdb_key, &bdb_value, 0); #endif if(ret) { dbc->c_close(dbc); return 1; } /* finally - delete the sucker */ ret=dbc->c_del(dbc, 0); dbc->c_close(dbc); #else /* V1 prototype: * int db->seq(DB* db, DBT *key, DBT *data, u_int flags); */ ret=bdb->seq(bdb, &bdb_key, &bdb_value, 0); if(ret) return 1; /* V1 prototype: * int db->del(DB* db, DBT *key, u_int flags); */ ret=bdb->del(bdb, &bdb_key, R_CURSOR); #endif if(ret) LIBRDF_DEBUG2("BDB del failed - %d\n", ret); return (ret != 0); }
/** * librdf_hash_bdb_cursor_get - Retrieve a hash value for the given key * @context: BerkeleyDB hash cursor context * @key: pointer to key to use * @value: pointer to value to use * @flags: flags * * Return value: non 0 on failure **/ static int librdf_hash_bdb_cursor_get(void* context, librdf_hash_datum *key, librdf_hash_datum *value, unsigned int flags) { librdf_hash_bdb_cursor_context *cursor=(librdf_hash_bdb_cursor_context*)context; #ifdef HAVE_BDB_CURSOR DBC *bdb_cursor=cursor->cursor; #else /* For BDB V1 */ DB* db; #endif DBT bdb_key; DBT bdb_value; int ret; /* docs say you must zero DBT's before use */ memset(&bdb_key, 0, sizeof(DBT)); memset(&bdb_value, 0, sizeof(DBT)); /* Always initialise BDB version of key */ bdb_key.data = (char*)key->data; bdb_key.size = key->size; #ifdef DB_DBT_MALLOC /* BDB V2 or later? */ bdb_key.flags=DB_DBT_MALLOC; /* Return in malloc() allocated memory */ bdb_value.flags=DB_DBT_MALLOC; #endif #ifndef HAVE_BDB_CURSOR /* For BDB V1 */ db=cursor->hash->db; #endif switch(flags) { case LIBRDF_HASH_CURSOR_SET: #ifdef HAVE_BDB_CURSOR /* V2/V3 prototype: * int DBcursor->c_get(DBC *cursor, DBT *key, DBT *data, u_int32_t flags); */ ret=bdb_cursor->c_get(bdb_cursor, &bdb_key, &bdb_value, DB_SET); #else /* V1 */ ret=db->seq(db, &bdb_key, &bdb_value, 0); #endif break; case LIBRDF_HASH_CURSOR_FIRST: #ifdef HAVE_BDB_CURSOR /* V2/V3 prototype: * int DBcursor->c_get(DBC *cursor, DBT *key, DBT *data, u_int32_t flags); */ ret=bdb_cursor->c_get(bdb_cursor, &bdb_key, &bdb_value, DB_FIRST); #else /* V1 */ ret=db->seq(db, &bdb_key, &bdb_value, R_FIRST); #endif break; case LIBRDF_HASH_CURSOR_NEXT_VALUE: #ifdef HAVE_BDB_CURSOR /* V2/V3 */ ret=bdb_cursor->c_get(bdb_cursor, &bdb_key, &bdb_value, DB_NEXT); #else /* V1 */ ret=db->seq(db, &bdb_key, &bdb_value, R_NEXT); #endif /* If succeeded and key has changed, end */ if(!ret && cursor->last_key && memcmp(cursor->last_key, bdb_key.data, bdb_key.size)) { /* always allocated by BDB using system malloc */ SYSTEM_FREE(bdb_key.data); SYSTEM_FREE(bdb_value.data); #ifdef DB_NOTFOUND /* V2 and V3 */ ret=DB_NOTFOUND; #else ret=1; #endif } break; case LIBRDF_HASH_CURSOR_NEXT: #ifdef HAVE_BDB_CURSOR #ifdef DB_NEXT_NODUP /* V3 */ /* Get next key, or next key/value (when value defined) */ ret=bdb_cursor->c_get(bdb_cursor, &bdb_key, &bdb_value, (value) ? DB_NEXT : DB_NEXT_NODUP); #else /* V2 */ /* Must mess about finding next key - note this relies on * the bdb btree having the keys in sorted order */ while(1) { ret=bdb_cursor->c_get(bdb_cursor, &bdb_key, &bdb_value, DB_NEXT); /* finish on error, want all values or no previous key */ if(ret || value || !cursor->last_key) break; /* else have previous key and want unique keys, so keep * going until the key changes */ if(memcmp(cursor->last_key, bdb_key.data, bdb_key.size)) break; /* always allocated by BDB using system malloc */ SYSTEM_FREE(bdb_key.data); SYSTEM_FREE(bdb_value.data); } #endif #else /* V1 */ ret=db->seq(db, &bdb_key, &bdb_value, R_NEXT); #endif break; default: LIBRDF_ERROR2(cursor->hash->hash->world, "Unknown hash method flag %d\n", flags); return 1; } /* Free previous key and values */ if(cursor->last_key) { LIBRDF_FREE(cstring, cursor->last_key); cursor->last_key=NULL; } if(cursor->last_value) { LIBRDF_FREE(cstring, cursor->last_value); cursor->last_value=NULL; } if(ret) { #ifdef DB_NOTFOUND /* V2 and V3 */ if(ret != DB_NOTFOUND) LIBRDF_DEBUG2("BDB cursor error - %d\n", ret); #endif key->data=NULL; return ret; } cursor->last_key = key->data = LIBRDF_MALLOC(cstring, bdb_key.size); if(!key->data) { /* always allocated by BDB using system malloc */ if(flags != LIBRDF_HASH_CURSOR_SET) SYSTEM_FREE(bdb_key.data); SYSTEM_FREE(bdb_value.data); return 1; } memcpy(key->data, bdb_key.data, bdb_key.size); key->size = bdb_key.size; if(value) { cursor->last_value = value->data = LIBRDF_MALLOC(cstring, bdb_value.size); if(!value->data) { /* always allocated by BDB using system malloc */ if(flags != LIBRDF_HASH_CURSOR_SET) SYSTEM_FREE(bdb_key.data); SYSTEM_FREE(bdb_value.data); return 1; } memcpy(value->data, bdb_value.data, bdb_value.size); value->size = bdb_value.size; } /* always allocated by BDB using system malloc */ if(flags != LIBRDF_HASH_CURSOR_SET) SYSTEM_FREE(bdb_key.data); SYSTEM_FREE(bdb_value.data); return 0; }
/** * librdf_hash_bdb_open - Open and maybe create a BerkeleyDB hash * @context: BerkeleyDB hash context * @identifier: filename to use for BerkeleyDB file * @mode: file creation mode * @is_writable: is hash writable? * @is_new: is hash new? * @options: hash options (currently unused) * * Return value: non 0 on failure. **/ static int librdf_hash_bdb_open(void* context, char *identifier, int mode, int is_writable, int is_new, librdf_hash* options) { librdf_hash_bdb_context* bdb_context=(librdf_hash_bdb_context*)context; DB* bdb; char *file; int ret; int flags; LIBRDF_ASSERT_OBJECT_POINTER_RETURN_VALUE(identifier, cstring, 1); #ifdef HAVE_DB_OPEN DB_INFO bdb_info; #endif /* NOTE: If the options parameter is ever used here, the data must be * copied into a private part of the context so that the clone * method can access them */ bdb_context->mode=mode; bdb_context->is_writable=is_writable; bdb_context->is_new=is_new; file=(char*)LIBRDF_MALLOC(cstring, strlen(identifier)+4); if(!file) return 1; sprintf(file, "%s.db", identifier); #ifdef HAVE_DB_CREATE /* V3 prototype: * int db_create(DB **dbp, DB_ENV *dbenv, u_int32_t flags); */ if((ret=db_create(&bdb, NULL, 0))) { LIBRDF_DEBUG2("Failed to create BDB context - %d\n", ret); return 1; } #ifdef HAVE_BDB_SET_FLAGS if((ret=bdb->set_flags(bdb, DB_DUP))) { LIBRDF_DEBUG2("Failed to set BDB duplicate flag - %d\n", ret); return 1; } #endif /* V3 prototype: * int DB->open(DB *db, const char *file, const char *database, * DBTYPE type, u_int32_t flags, int mode); */ flags=is_writable ? DB_CREATE : DB_RDONLY; if(is_new) flags |= DB_TRUNCATE; #endif #if defined(HAVE_BDB_OPEN_6_ARGS) || defined(HAVE_BDB_OPEN_7_ARGS) #ifdef HAVE_BDB_OPEN_6_ARGS /* * int DB->open(DB *db, const char *file, * const char *database, DBTYPE type, u_int32_t flags, int mode); */ if((ret=bdb->open(bdb, file, NULL, DB_BTREE, flags, mode))) { librdf_error(bdb_context->hash->world, "BDB V4.0+ open of '%s' failed - %s", file, db_strerror(ret)); LIBRDF_FREE(cstring, file); return 1; } #else /* Must be HAVE_BDB_OPEN_7_ARGS */ /* * int DB->open(DB *db, DB_TXN *txnid, const char *file, * const char *database, DBTYPE type, u_int32_t flags, int mode); */ if((ret=bdb->open(bdb, NULL, file, NULL, DB_BTREE, flags, mode))) { librdf_error(bdb_context->hash->world, "BDB V4.1+ open of '%s' failed - %s", file, db_strerror(ret)); LIBRDF_FREE(cstring, file); return 1; } #endif #else #ifdef HAVE_DB_OPEN /* V2 prototype: * int db_open(const char *file, DBTYPE type, u_int32_t flags, * int mode, DB_ENV *dbenv, DB_INFO *dbinfo, DB **dbpp); */ memset(&bdb_info, 0, sizeof(DB_INFO)); bdb_info.flags=DB_DUP; flags=is_writable ? DB_CREATE : DB_RDONLY; if(is_new) flags |= DB_TRUNCATE; if((ret=db_open(file, DB_BTREE, flags, mode, NULL, &bdb_info, &bdb))) { librdf_error(bdb_context->hash->world, "BDB V2 open of '%s' failed - %d", file, ret); LIBRDF_FREE(cstring, file); return 1; } #else #ifdef HAVE_DBOPEN /* V1 prototype: const char *file, int flags, int mode, DBTYPE, const void *openinfo */ flags=is_writable ? O_RDWR|O_CREAT : O_RDONLY flags|=R_DUP; /* There does not seem to be a V1 flag for truncate */ if(is_new) remove(file); if((bdb=dbopen(file, flags, mode, DB_BTREE, NULL)) == 0) { librdf_error(bdb_context->hash->world, "BDB V1 open of '%s' failed - %d", file, ret); LIBRDF_FREE(cstring, file); return 1; } ret=0; #else #ifdef HAVE_DB_CREATE /* earlier */ #else ERROR - no idea how to use Berkeley DB #endif #endif #endif #endif bdb_context->db=bdb; bdb_context->file_name=file; return 0; }
/** * librdf_serializer_register_factory: * @world: redland world object * @name: the name of the serializer * @label: the label of the serializer (optional) * @mime_type: MIME type of the syntax (optional) * @uri_string: URI of the syntax (optional) * @factory: function to be called to register the factor parameters * * Register a serializer factory . * **/ REDLAND_EXTERN_C void librdf_serializer_register_factory(librdf_world *world, const char *name, const char *label, const char *mime_type, const unsigned char *uri_string, void (*factory) (librdf_serializer_factory*)) { librdf_serializer_factory *serializer; librdf_world_open(world); #if defined(LIBRDF_DEBUG) && LIBRDF_DEBUG > 1 LIBRDF_DEBUG2("Received registration for serializer %s\n", name); #endif if(!world->serializers) { world->serializers = raptor_new_sequence((raptor_data_free_handler)librdf_free_serializer_factory, NULL); if(!world->serializers) goto oom; } serializer=(librdf_serializer_factory*)LIBRDF_CALLOC(librdf_serializer_factory, 1, sizeof(librdf_serializer_factory)); if(!serializer) goto oom; serializer->name=(char*)LIBRDF_MALLOC(cstring, strlen(name)+1); if(!serializer->name) goto oom_tidy; strcpy(serializer->name, name); if(label) { serializer->label=(char*)LIBRDF_MALLOC(cstring, strlen(label)+1); if(!serializer->label) goto oom_tidy; strcpy(serializer->label, label); } /* register mime type if any */ if(mime_type) { serializer->mime_type=(char*)LIBRDF_MALLOC(cstring, strlen(mime_type)+1); if(!serializer->mime_type) goto oom_tidy; strcpy(serializer->mime_type, mime_type); } /* register URI if any */ if(uri_string) { serializer->type_uri=librdf_new_uri(world, uri_string); if(!serializer->type_uri) goto oom_tidy; } if(raptor_sequence_push(world->serializers, serializer)) goto oom; /* Call the serializer registration function on the new object */ (*factory)(serializer); #if defined(LIBRDF_DEBUG) && LIBRDF_DEBUG > 1 LIBRDF_DEBUG3("%s has context size %d\n", name, serializer->context_length); #endif return; oom_tidy: librdf_free_serializer_factory(serializer); oom: LIBRDF_FATAL1(world, LIBRDF_FROM_SERIALIZER, "Out of memory"); }