[PD-dev] how to dinamically allocate t_atom & t_float size?

Jonathan Wilkes jancsika at yahoo.com
Sat Dec 5 17:37:24 CET 2020


> then alloca() is IMO the best tool for the job. It is not only simpler but also faster than pre-allocation, because the stack memory is much more likely to be in cache.
I'm not sure that's quite constrained enough yet. Not only do we want to avoid an arbitrary user-controlled upper bound, we don't want future devs adding the "feature" of an arbitrary user-controlled upper bound, or even a new upper bound that isn't user-controlled but is still too high given what you and I know about alloca.

So unless those constraints are documented in the code, this is still asking for trouble. And history of trouble is scattered throughout the usage history of alloca in Pd and elsewhere.
I'm willing to concede that "Don't use alloca," is a bit like, "eval is evil." But given the proliferation of wrong uses of alloca I believe it's warranted. At least here we've gone from avoiding a call to free to a list of very niche constraints.

Best,
Jonathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20201205/ea41c07b/attachment.html>


More information about the Pd-dev mailing list