Im having a little problem with dynamic arrays..
I have a struct:
i declare a pointer to that struct:
typedef struct _SFont
My class constructor:
I have a function that increases the fontnum and must resize the array:
rFont = (SFont*)malloc(sizeof *rFont);
fontnum = 0; //fontnum is a counter
There is some code to create a font, but thats all we need. The problem is that I can only call 1 time this function, meaning that I can only add 1 more font. If i call it again, it crashes! I free the array using:
void ObjectBuilder::CreateFont(char *Name, int size)
fontnum += 1;
//allocate more space
rFont = (SFont*)realloc(rFont, fontnum * sizeof *rFont);
//So, now the array should have fontnum-1 slots, right?
rFont[fontnum].Name = Name;
But when I exit the program, having created 1 font, it crashes for once more in the debug and shows me some asm code. Thank you very much!