hello!
why do the librdf destructors not handle 0 arguments correctly?
i.e. they should just return, and not segfault like they currently do.
after all, the C free function and the C++ operator delete handle 0
arguments the same, so i would guess that many people would implictily
assume that anything that frees stuff acts the same way.
so, since writing this patch was less work than fixing the >2k lines of
code that i wrote last week, here is a patch that fixes all the publicly
documented librdf_free_foo functions.
will this go in the next release?
regards,
michael stahl
PS: just for the record, i would find it useful if there were a tarball of
librdf that does not contain raptor and rasqal
--
"[The academic world] has to refine and to teach to the best of its
abilities how computing should be done; would it ever yield to the
pressure to propagate the malpractice of today, it had better fold up."
-- Edsger W. Dijkstra
diff -ur redland-1.0.7/librdf/rdf_digest.c redland-1.0.7-free/librdf/rdf_digest.c
--- redland-1.0.7/librdf/rdf_digest.c Wed Dec 5 18:25:18 2007
+++ redland-1.0.7-free/librdf/rdf_digest.c Wed Apr 23 17:36:46 2008
@@ -250,6 +250,8 @@
void
librdf_free_digest(librdf_digest *digest)
{
+ if(!digest)
+ return;
if(digest->context)
LIBRDF_FREE(digest_context, digest->context);
if(digest->digest)
diff -ur redland-1.0.7/librdf/rdf_hash.c redland-1.0.7-free/librdf/rdf_hash.c
--- redland-1.0.7/librdf/rdf_hash.c Thu Dec 20 22:39:42 2007
+++ redland-1.0.7-free/librdf/rdf_hash.c Wed Apr 23 17:36:54 2008
@@ -490,6 +490,8 @@
void
librdf_free_hash(librdf_hash* hash)
{
+ if(!hash)
+ return;
if(hash->context) {
if(hash->is_open)
librdf_hash_close(hash);
diff -ur redland-1.0.7/librdf/rdf_init.c redland-1.0.7-free/librdf/rdf_init.c
--- redland-1.0.7/librdf/rdf_init.c Tue Nov 6 16:26:18 2007
+++ redland-1.0.7-free/librdf/rdf_init.c Wed Apr 23 17:50:49 2008
@@ -178,6 +178,9 @@
void
librdf_free_world(librdf_world *world)
{
+ if(!world)
+ return;
+
/* NOTE: raptor is always initialised as a parser and may
* be also used as a serializer, but it is NOT finished
* in the serializer_raptor registration. Therefore, always
diff -ur redland-1.0.7/librdf/rdf_list.c redland-1.0.7-free/librdf/rdf_list.c
--- redland-1.0.7/librdf/rdf_list.c Thu Dec 20 22:39:42 2007
+++ redland-1.0.7-free/librdf/rdf_list.c Wed Apr 23 17:37:52 2008
@@ -108,6 +108,8 @@
void
librdf_free_list(librdf_list* list)
{
+ if(!list)
+ return;
LIBRDF_ASSERT_RETURN(list->iterator_count,
"Iterators were active on freeing list", );
diff -ur redland-1.0.7/librdf/rdf_model.c redland-1.0.7-free/librdf/rdf_model.c
--- redland-1.0.7/librdf/rdf_model.c Tue Oct 23 16:55:06 2007
+++ redland-1.0.7-free/librdf/rdf_model.c Wed Apr 23 17:38:54 2008
@@ -393,7 +393,8 @@
librdf_iterator* iterator;
librdf_model* m;
- LIBRDF_ASSERT_OBJECT_POINTER_RETURN(model, librdf_model);
+ if(!model)
+ return;
if(--model->usage)
return;
diff -ur redland-1.0.7/librdf/rdf_node.c redland-1.0.7-free/librdf/rdf_node.c
--- redland-1.0.7/librdf/rdf_node.c Thu Dec 20 22:39:42 2007
+++ redland-1.0.7-free/librdf/rdf_node.c Wed Apr 23 17:39:39 2008
@@ -726,7 +726,8 @@
librdf_world *world;
#endif
- LIBRDF_ASSERT_OBJECT_POINTER_RETURN(node, librdf_node);
+ if(!node)
+ return;
#ifdef WITH_THREADS
world = node->world;
diff -ur redland-1.0.7/librdf/rdf_parser.c redland-1.0.7-free/librdf/rdf_parser.c
--- redland-1.0.7/librdf/rdf_parser.c Mon Dec 17 08:19:11 2007
+++ redland-1.0.7-free/librdf/rdf_parser.c Wed Apr 23 17:40:38 2008
@@ -371,7 +371,8 @@
void
librdf_free_parser(librdf_parser *parser)
{
- LIBRDF_ASSERT_OBJECT_POINTER_RETURN(parser, librdf_parser);
+ if(!parser)
+ return;
if(parser->context) {
if(parser->factory->terminate)
diff -ur redland-1.0.7/librdf/rdf_query.c redland-1.0.7-free/librdf/rdf_query.c
--- redland-1.0.7/librdf/rdf_query.c Tue Oct 23 16:55:06 2007
+++ redland-1.0.7-free/librdf/rdf_query.c Wed Apr 23 17:41:39 2008
@@ -388,7 +388,8 @@
void
librdf_free_query(librdf_query* query)
{
- LIBRDF_ASSERT_OBJECT_POINTER_RETURN(query, librdf_query);
+ if(!query)
+ return;
if(--query->usage)
return;
diff -ur redland-1.0.7/librdf/rdf_query_results.c redland-1.0.7-free/librdf/rdf_query_results.c
--- redland-1.0.7/librdf/rdf_query_results.c Fri Oct 26 04:23:36 2007
+++ redland-1.0.7-free/librdf/rdf_query_results.c Wed Apr 23 17:43:52 2008
@@ -244,7 +244,8 @@
void
librdf_free_query_results(librdf_query_results* query_results)
{
- LIBRDF_ASSERT_OBJECT_POINTER_RETURN(query_results, librdf_query_results);
+ if(!query_results)
+ return;
if(query_results->query->factory->free_results)
query_results->query->factory->free_results(query_results);
@@ -636,6 +637,8 @@
void
librdf_free_query_results_formatter(librdf_query_results_formatter* formatter)
{
+ if(!formatter)
+ return;
if(formatter->query_results->query->factory->free_results_formatter)
formatter->query_results->query->factory->free_results_formatter(formatter);
}
diff -ur redland-1.0.7/librdf/rdf_serializer.c redland-1.0.7-free/librdf/rdf_serializer.c
--- redland-1.0.7/librdf/rdf_serializer.c Tue Oct 23 16:55:06 2007
+++ redland-1.0.7-free/librdf/rdf_serializer.c Wed Apr 23 17:45:08 2008
@@ -373,7 +373,8 @@
void
librdf_free_serializer(librdf_serializer *serializer)
{
- LIBRDF_ASSERT_OBJECT_POINTER_RETURN(serializer, librdf_serializer);
+ if(!serializer)
+ return;
if(serializer->context) {
if(serializer->factory->terminate)
diff -ur redland-1.0.7/librdf/rdf_statement.c redland-1.0.7-free/librdf/rdf_statement.c
--- redland-1.0.7/librdf/rdf_statement.c Tue Nov 6 16:26:18 2007
+++ redland-1.0.7-free/librdf/rdf_statement.c Wed Apr 23 17:45:53 2008
@@ -255,7 +255,8 @@
librdf_world *world;
#endif
- LIBRDF_ASSERT_OBJECT_POINTER_RETURN(statement, librdf_statement);
+ if(!statement)
+ return;
#ifdef WITH_THREADS
world = statement->world;
diff -ur redland-1.0.7/librdf/rdf_storage.c redland-1.0.7-free/librdf/rdf_storage.c
--- redland-1.0.7/librdf/rdf_storage.c Thu Dec 20 22:39:42 2007
+++ redland-1.0.7-free/librdf/rdf_storage.c Wed Apr 23 17:46:50 2008
@@ -608,7 +608,8 @@
void
librdf_free_storage (librdf_storage* storage)
{
- LIBRDF_ASSERT_OBJECT_POINTER_RETURN(storage, librdf_storage);
+ if(!storage)
+ return;
if(--storage->usage)
return;
diff -ur redland-1.0.7/librdf/rdf_stream.c redland-1.0.7-free/librdf/rdf_stream.c
--- redland-1.0.7/librdf/rdf_stream.c Mon Dec 24 00:23:10 2007
+++ redland-1.0.7-free/librdf/rdf_stream.c Wed Apr 23 17:47:41 2008
@@ -126,6 +126,9 @@
void
librdf_free_stream(librdf_stream* stream)
{
+ if(!stream)
+ return;
+
if(stream->finished_method)
stream->finished_method(stream->context);
diff -ur redland-1.0.7/librdf/rdf_uri.c redland-1.0.7-free/librdf/rdf_uri.c
--- redland-1.0.7/librdf/rdf_uri.c Tue Oct 23 16:55:06 2007
+++ redland-1.0.7-free/librdf/rdf_uri.c Wed Apr 23 17:48:28 2008
@@ -409,7 +409,8 @@
librdf_world *world;
#endif
- LIBRDF_ASSERT_OBJECT_POINTER_RETURN(uri, librdf_uri);
+ if(!uri)
+ return;
#ifdef WITH_THREADS
world = uri->world;
_______________________________________________
redland-dev mailing list
[email protected]
http://lists.librdf.org/mailman/listinfo/redland-dev