[PD] another free c lesson: realloc

Jonathan Wilkes jancsika at yahoo.com
Wed Aug 19 17:32:29 CEST 2015


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20150819/68b546cd/attachment.html>


More information about the Pd-list mailing list