Additional Space

Sometimes the space requirement of a module is too large to be part of a structure (upper limit 65535 bytes), or it is dependent on an i-arg value which is not known until initialization. Additional space can be dynamically allocated and properly managed by including the line

AUXCH      auxch;
        

in the defined structure (*p), then using the following style of code in the init module:

if (p-auxch.auxp == NULL)
  auxalloc(npoints * sizeof(float), &p-auxch);
        

The address of this auxiliary space is kept in a chain of such spaces belonging to this instrument, and is automatically managed while the instrument is being duplicated or garbage-collected during performance. The assignment

char *auxp = p-auxch.auxp;
        

will find the allocated space for init-time and perf-time use. See the LINSEG structure in opcodes1.h and the code for lsgset() and klnseg() in opcodes1.c.