I have a generic application which basically reads a file following a specific format. This requires me to allocate memory depending on the file's attributes, and such. The maximum memory the file will ask me to allocate is 65535 bytes. But keep in mind, I allocate in 5 different sections, in which, the maximum bytes the file would ask me to allocate is 65535 bytes, as I said before.
So basically, if the file has reached its maximum, I will have to allocate:
65535 * 5 = 327675 bytes.
malloc() obviously fails in one of these sections. A static array is not a solution either since it is also, too much memory.
Basically, each one of the "members" that I have to allocate memory for are in the same structure. So in code, it is something like:
Any ideas?Code:typedef struct { void *section_1; /*Required max storage capacity: 65535 bytes*/ void *section_2; /*Required max storage capacity: 65535 bytes*/ void *section_3; /*Required max storage capacity: 65535 bytes*/ void *section_4; /*Required max storage capacity: 65535 bytes*/ void *section_5; /*Required max storage capacity: 65535 bytes*/ } file;