I have a loop which essentially looks like:
for(i=0; i<imax; i++)
fscanf(inputfile,"%d",&data_size); // line 1
data_pointer[i]=new char[data_size]; // line 2
It is quite possible that at some point the system may run out of memory, failing to allocate whatever is needed in line 2. I want to predict this failure. Is there a way to find the potentially available memory size right after line 1 so that line 2 can be avoided if memory is too low ?
(Certainly I can preset data_pointer to NULL, and see if it changed in line 2 - but this happens after the allocation failure, with Windows "Out of memory" box already on my screen)