Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum wrote:
The reference to the old array on the stack is removed by f_add(). So the extra reference you should be worried about is the one in _datarows. Because as long as the variable in the object holds a reference to the old array, it can not be destructively modified. I expect setting _datarows to 0 after the index_no_free2() but before the f_add() should do the trick, but maybe there is a more elegant solution?
Well, I went with this:
f_aggregate(nrows); Pike_sp++; object_index_no_free2(Pike_sp-1, portal,0, MK_STRING_SVALUE("_datarows")); if(Pike_sp[-1].u.array->size) { push_undefined(); object_set_index2(portal,0, MK_STRING_SVALUE("_datarows"), Pike_sp-1); pop_stack(); stack_swap(); f_add(2); } else pop_stack(); object_set_index2(portal,0, MK_STRING_SVALUE("_datarows"), Pike_sp-1); pop_stack();
Because, as it turns out, in most cases, the array is empty before we start.