[redland-dev] implicit free
Lauri Aalto
laalto at gmail.com
Fri Nov 25 11:28:41 CET 2011
Hello,
from docs http://librdf.org/docs/api/redland-statement.html#librdf-new-statement-from-nodes
"The node objects become owned by the new statement (or freed on error)."
Being an owner for some object means being responsible for freeing it.
Generally, ownership transfers are quite well documented in Redland
API documentation. If there's no mention of ownership transfer, the
argument object is copied if needed.
Also, most objects are reference-counted so copying an object is
cheap, simply incrementing a usage counter. This implies that the
objects are shared - modifying one also modifies the copies. If this
is not what you want, you'll need to implement explicit copy-on-write
yourself.
Lauri
On Fri, Nov 25, 2011 at 12:12 PM, Maxence Guesdon
<Maxence.Guesdon at inria.fr> wrote:
> Hello,
>
> Sorry if the answer is obvious but...
>
> Looking at example1.c:
> https://github.com/dajobe/librdf/blob/master/examples/example1.c
> Line 104, a new statement is created from nodes.
> Line 111, the statement is freed.
>
> I wonder if freeing the statement also frees the nodes.
> In fact, I wonder if there is a kind of recursive free through all
> structures.
>
> Context: I just began an OCaml binding to librdf and I'm trying to play
> well with the garbage collector.
>
> Regards,
>
> --
> Maxence Guesdon
>
> _______________________________________________
> redland-dev mailing list
> redland-dev at lists.librdf.org
> http://lists.librdf.org/mailman/listinfo/redland-dev
>
More information about the redland-dev
mailing list