[redland-dev] Re: [patch] librdf_free_foo(0)

Dave Beckett dave at dajobe.org
Fri Apr 25 06:52:13 BST 2008


Michael Stahl wrote:
> Sebastian Trüg wrote:
>> Full ack. I actually wrote myself wrapper methods for that but then 
>> again I am a C++ developer....
> 
> well, yes, all of my code looks like this:
> 
>     const boost::shared_ptr<librdf_node> pNode(
>         librdf_new_node_from_blank_identifier(m_pWorld.get(), NULL),
>         librdf_free_node);
>     if (!pNode) {
>         throw RuntimeException...
>     }
> so, imagine my surprise when i learned the hard way that that won't work :)

Well I don't do C++ and the above isn't something I've heard of
although skimming the boost docs I can guess.

I always thought free(NULL) was an application error but I can agree
that it shouldn't crash, so I don't see any problem with adding something
like that patch, although I might do it slightly differently so that
for redland configure --maintainer-mode it makes the destructors with
NULL do something else - warn & return.

Dave



More information about the redland-dev mailing list