It's hard to tell my problem in the title. However,
I'm programming a program that use a structure database. In this structure I have information about the database and the element of the database itself. Each element is another structure. For now I declared the elements whit a simply array of elements whit a defined size. But each element is heavy (6 long double, a char[64], some int and soon much more) and I want to make the program able to work on a lot of (possibly infinte) element simultaneously, so it's necessary to use a lot of RAM. But only sometimes the program fills the array, so the program occupies a lot of RAM and works only whit few element. So I thinked to use a binary tree, so when i want to put another element I initialize a new element structure, and when i delete it the program dealloc the structure and I can have "infintie" element. But two problems hit me:
1) If I call a function that allocs a new structure and return the pointer to it, the structure isn't automatic deallocated because the function is finished 2) The program alloc and dealloc element of the structure whitout order, so the array is perfect because is enought a boolean flag "active" or "unactive" for each structure, but in a tree, the things being more complicated, I have to delete the node, then relink his children to another node that hasn't children...
What do you think? Every suggestion is taken with thanks.