This is one way, maybe not the easiest. Build a dynamic data table. Set aside a chunk of memory and a variable for your index and/or iterator. If you want to start with 5 elements, start at the first location and build up (If you want a LIFO structure, start at the last location and build down).
Most of the standard I/O drivers do not use the upper portion of the HUB memory. The biggest exception is the graphics driver which is usually configured to have one or two screen buffers right at the end of HUB memory. Once upon a time, I had a Propeller OS that allocated work areas and buffers at the end of HUB memory by initializing a word to $8000 and decrementing this by the requested data area size before returning the resulting value (and storing it in the word used for it). This value was the start of the memory area to be used for the work area or buffer or array. You want to check this against the top of the run-time stack and leave some free stack area for the rest of the program to use, but that's the general scheme. There's no easy way to reuse the space, but, in this application, the allocated areas were always in use.
The CLIB object in the OBEX contains a heap manager. It is contained cmalloc.c. The mallocinit routine is called at the beginning of a program to initialize the heap and set a stack size for the top object. After that you can call malloc, calloc and free to allocate chunks of memory and free them.
What is the easiest way to do a "dynamic" array with a Prop?
Really, it can't be very dynamic, since there is a absolute max to the memory you can use. One technique is to cheat, use a couple buffers in RAM, and page them out to SD. Set the SD partitions (not files, but close enough) to the largest they are ever going to be, and start filling them up. I think Four buffers of 1K in Hub memory is the most we've needed so far.
Comments
Really, it can't be very dynamic, since there is a absolute max to the memory you can use. One technique is to cheat, use a couple buffers in RAM, and page them out to SD. Set the SD partitions (not files, but close enough) to the largest they are ever going to be, and start filling them up. I think Four buffers of 1K in Hub memory is the most we've needed so far.