summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-07-03 05:03:47 +0000
committerDavid Robillard <d@drobilla.net>2007-07-03 05:03:47 +0000
commite11a263a03a4d141ebb5d7b66cfff4831d4f5adc (patch)
tree45f081c385aeb44b2b67a9e159fa1af29e0a9c04 /src
parentfd072bfb096e6efd88de1e058a355128b312d6d8 (diff)
downloadlilv-e11a263a03a4d141ebb5d7b66cfff4831d4f5adc.tar.gz
lilv-e11a263a03a4d141ebb5d7b66cfff4831d4f5adc.tar.bz2
lilv-e11a263a03a4d141ebb5d7b66cfff4831d4f5adc.zip
Fail gracefully if redland is deeply screwed.
git-svn-id: http://svn.drobilla.net/lad/slv2@562 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/world.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/world.c b/src/world.c
index dc2be1a..1458124 100644
--- a/src/world.c
+++ b/src/world.c
@@ -35,14 +35,23 @@ slv2_world_new()
SLV2World world = (SLV2World)malloc(sizeof(struct _SLV2World));
world->world = librdf_new_world();
+ if (!world->world)
+ goto fail;
+
librdf_world_open(world->world);
world->storage = librdf_new_storage(world->world, "hashes", NULL,
"hash-type='memory'");
+ if (!world->storage)
+ goto fail;
world->model = librdf_new_model(world->world, world->storage, NULL);
+ if (!world->model)
+ goto fail;
world->parser = librdf_new_parser(world->world, "turtle", NULL, NULL);
+ if (!world->parser)
+ goto fail;
world->plugin_classes = slv2_plugin_classes_new();
@@ -58,8 +67,12 @@ slv2_world_new()
world->rdf_a_node = librdf_new_node_from_uri_string(world->world,
(unsigned char*)"http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
-
+
return world;
+
+fail:
+ free(world);
+ return NULL;
}
@@ -69,13 +82,19 @@ slv2_world_new_using_rdf_world(librdf_world* rdf_world)
SLV2World world = (SLV2World)malloc(sizeof(struct _SLV2World));
world->world = rdf_world;
-
+
world->storage = librdf_new_storage(world->world, "hashes", NULL,
"hash-type='memory'");
+ if (!world->storage)
+ goto fail;
world->model = librdf_new_model(world->world, world->storage, NULL);
+ if (!world->model)
+ goto fail;
world->parser = librdf_new_parser(world->world, "turtle", NULL, NULL);
+ if (!world->parser)
+ goto fail;
world->plugin_classes = slv2_plugin_classes_new();
@@ -93,6 +112,10 @@ slv2_world_new_using_rdf_world(librdf_world* rdf_world)
(unsigned char*)"http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
return world;
+
+fail:
+ free(world);
+ return NULL;
}