On 10.03.2012 21:34, Anand Avati wrote:
There is a no rule written on stone here. It is good practice to makecopies. 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