You could also do like the following:
typedef struct idata {
sometype data1;
sometype2 data2;
struct idata *next;
} idata;
You can then create a string of idata structs and access the next one. You
will have to create a function that will allocate a new one under
idata->next when needed, a function to search them and a function to free
the string. When creating a new one always make idata->next = NULL so that
you can use it to determine if you have reached the end of the string.
This is what is done in WAPUniverse.
-Donald
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> Hi all,
>
> I'm having a bit of difficulty figuring out how to allocate memory for a
structure that contains an array of structures.
>
> I found some sample code on how to allocate memory for such a setup, as
follows:
>
> pdat = (struct pdata *) MemPtrNew(sizeof(struct pdata));
> pdat->idat = (struct idata *)MemPtrNew(5 * sizeof(struct idata));
>
> This code will allocate a structure called pdat as well as allocate memory
for an array of five idat structures within the pdat structure.
>
> How would I go about allocating memory for this structure if I didn't know
beforehand the number of idat structures will exist in the array? Or is
this information absolutely required in order to do this?
>
> Thanks.
>
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/