[Gluster-devel] Can function arguments be modified ?
Xavier Hernandez
xhernandez at datalab.es
Sun Mar 11 08:34:01 UTC 2012
On 10.03.2012 21:34, Anand Avati wrote:
> There is a no rule
written on stone here. It is good practice to make
>
> copies. Note
that for things like iatt structure, you need not
> "allocate" and
"free" from the heap. Most of the time you can copy to
> a structure on
the stack, modify and return that. You will see that
> for parameters
which get modified in the callback (typically
> aggregated from multiple
subvolumes), most translators have a
> "modified" copy inside
frame->local.
>
> Avati
Basically my problem was with dict_t. I
already make copies of iatt and other simple structures without explicit
memory allocation. These are cheap but anyway, if that were unnecessary,
better not doing needless work.
So, in general I can assume that all
translators will make a copy if they modify any argument I pass to them,
and I can use a COW (copy on write) policy for all structures I receive,
either regular or callback calls. Right ?
I had already seen that some
translators were making copies, but I hadn't found any "official"
statement saying that this was the way to do it. I just wanted to be
sure.
Thank you very much
Xavi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://supercolony.gluster.org/pipermail/gluster-devel/attachments/20120311/51ced150/attachment-0003.html>
More information about the Gluster-devel
mailing list