126.96.36.199. On the proper usage of the “rowDeepCopy()” function
The proper usage of this function requires a little bit more explanations. There are basically two “use cases” when you need to use the “rowDeepCopy()” function:
Let’s go back to our example of section 188.8.131.52:
On line 12 of the above script, we used the global function “rowDeepCopy()”.
Let’s first examine what’s happening if the line 12 is missing:
The line 12 is present: Everything is ok:
The instruction “r1=rowDeepCopy(r1)” will create a completely new fresh copy of the row “r1” into a newly allocated memory buffer. In software terms, Anatella performs a “deep copy” of the “r1” row object (and places the copy into “r1” again). The variable “r1” is now sharing its memory buffer with NO other variable. In this situation, the call to the “getNextRow()” function, on line 16 is totally harmless.
To summarize: There exists one memory buffer per input pin. This memory buffer is shared by all the “Row objects” obtained using previous calls to the “getNextRow()” or “getCurrentRow()” functions. When you call the “getNextRow(pinP)” function, all the “Row objects” obtained using the “getNextRow(pinP)” or “getCurrentRow(pinP)” functions are invalidated: you cannot use them anymore. If you want to still be able to use an old Row object “R” after a call to the “getNextRow(pinP)” function, you must perform a deep copy of your Row object “R” (using the “rowDeepCopy()” function).
Since the “r1” and “r2” variables are manipulating the same Row Object, the instruction on line 3 will never have any effect at all because its effect is overridden by the instruction on line 4. To obtain a completely separated copy of a “Row object”, use the “rowDeepCopy(rowObject)” global function. Here is the same example with the appropriate correction:
Here is an even better correction: