[PD-dev] How to construct a dynamic length list in PD external?

Claude Heiland-Allen claudiusmaximus at goto10.org
Sat Mar 21 01:02:08 CET 2009


B. Bogart wrote:
> Hey all,
> 
> I searched the archives and looked at some of the code in SVN, but I'm
> still unsure how to do this.
> 
> I have a nested for loop that grabs the config options from the PTP
> camera. The length depends on the camera and its mode.
> 
> How can I append each name to a list suitable to be used by outlet_list?

choice 1 (if maximum length is known):

allocate t_atom out[MAX_LENGTH] on the stack (as a normal variable). 
set argc to the actual length.

choice 2 (if maximum length is not known):

loop through once to get the length
malloc() sufficient space
loop through again to copy the data
send to outlet
free() the space

choice 3 (an alternative):

send each config option to the outlet separately (may be more useful 
than having to parse a list later?)


Claude
-- 
http://claudiusmaximus.goto10.org




More information about the Pd-dev mailing list