gluster-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gluster-devel] Can function arguments be modified ?


From: Xavier Hernandez
Subject: Re: [Gluster-devel] Can function arguments be modified ?
Date: Sun, 11 Mar 2012 09:34:01 +0100
User-agent: Roundcube Webmail/0.7.1

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]