mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-07-04 21:50:35 -04:00
Corrected the memory exhaustion trap behavior used when calling realloc
Two more steps are currently required to complete hitutils: write hitld, with support for multiple objects and even .a archives, and implement scan_branch_destinations in hitdump. Then we can seamless modify The Sims 1's HIT routines.
This commit is contained in:
parent
0ec39fd968
commit
558726a9f1
3 changed files with 14 additions and 9 deletions
|
@ -82,9 +82,12 @@ struct RTTIVector {
|
|||
Shutdown_M("Failed to allocate memory");
|
||||
}
|
||||
T& add(){
|
||||
if((Count+1)*sizeof(T) > SizeAllocated)
|
||||
if(SizeAllocated > SIZE_MAX/2 || !(Buffer = (T*) realloc(Buffer, SizeAllocated<<=1)))
|
||||
if((Count+1)*sizeof(T) > SizeAllocated){
|
||||
void * ptr;
|
||||
if(SizeAllocated > SIZE_MAX/2 || !(ptr = (T*) realloc(Buffer, SizeAllocated<<=1)))
|
||||
Shutdown_M("Failed to allocate memory");
|
||||
Buffer = (T *) ptr;
|
||||
}
|
||||
|
||||
return Buffer[Count++];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue