Posted By: Ayumi
Struct Array mit Entity Array - Dynamic - 01/01/17 12:34
Hey,
i would like to expand dynamically an array of structs with an array of Entitys(or any other)....separated from each other.
How to without memory leaks and Errors?
Get an unknown Error, if loop through "Ents".
i would like to expand dynamically an array of structs with an array of Entitys(or any other)....separated from each other.
How to without memory leaks and Errors?
Code:
typedef struct Flare { int Count; ENTITY* Ents[1]; // dynamic } Flare; Flare* Flares[1]; // -> dynamic void AllocateNew() { Flares = sys_malloc(sizeof(Flare) * 20); // Later in Code: Flares[0].Ents = sys_malloc(sizeof(Flare) + (count * sizeof(ENTITY))); }
Get an unknown Error, if loop through "Ents".