Looked at this again and I can't seem to induce an error or crash. But I also
cannot understand how gp_w can be used to reliably refer to an element in a
dynamically allocated byte array.
Doesn't this stackoverflow discussion apply
here?http://stackoverflow.com/questions/2172127/how-to-update-other-pointers-when-realloc-moves-the-memory-block
Thanks,Jonathan
On Wednesday, August 19, 2015 11:33 AM, Jonathan Wilkes via Pd-list
<[email protected]> wrote:
Hi list,So I'm looking at t_gpointer in m_pd.h, and I'm noticing that for
arrays it has gp_w which is a union _word pointer. This is the raw data that I
was asking about in my previous request for a free lesson. :)
However, in the code for [setsize] the data is resized dynamically using
realloc.
So...
Suppose I have a [pointer] in a patch which is pointing to a nested array, and
a [setsize] which is pointing to the container array. If I send an enormous
float to [setsize], isn't it likely that realloc will move the data and my
[pointer] data will silently become stale? After all, gp_w has no idea if
realloc moves the data. Seems like it'd be pointing to the wrong place and
likely to cause a crash.
I don't have access to a running Pd instance atm, otherwise I'd test...
Thanks,Jonathan
_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management ->
http://lists.puredata.info/listinfo/pd-list
_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management ->
http://lists.puredata.info/listinfo/pd-list