mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-07-08 07:30:29 -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
|
@ -58,9 +58,10 @@ typedef struct {
|
|||
} ByteWriterContext;
|
||||
|
||||
static void bw_expand(ByteWriterContext *bwc){
|
||||
bwc->Data = realloc(bwc->Data, (bwc->Size <<= 1));
|
||||
if(!bwc->Data)
|
||||
void * ptr;
|
||||
if(bwc->Size > SIZE_MAX/2 || !(ptr = realloc(bwc->Data, bwc->Size<<=1)))
|
||||
Shutdown_M("%sCould not allocate memory for %s section.\n", "hitasm: Error: ", bwc->Name);
|
||||
bwc->Data = ptr;
|
||||
}
|
||||
|
||||
static void bw_write32(ByteWriterContext *bwc, uint32_t value){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue