Fix bug where RomLink handles weren't locked

Pointers to relocatable blocks were being kept and re-used! Now HLock is
correctly used to keep the blocks in place. This is Memory Manager 101.
This commit is contained in:
Elliot Nunn 2018-02-03 11:40:54 +08:00
parent 6788160911
commit a855f682c6
1 changed files with 6 additions and 1 deletions

View File

@ -61,6 +61,9 @@ void get_program(unsigned char **prog_p, long *len_p, unsigned char *name)
fprintf(stderr, "Could not find program \"%.*s\"\n", *name, name+1);
}
MoveHHi(hdl);
HLock(hdl);
*prog_p = *(unsigned char **)hdl;
*len_p = GetHandleSize(hdl);
}
@ -68,7 +71,9 @@ void get_program(unsigned char **prog_p, long *len_p, unsigned char *name)
void free_program(unsigned char *prog)
{
DisposeHandle(RecoverHandle((Ptr)prog));
Handle hdl = RecoverHandle((Ptr)prog);
HUnlock(hdl);
DisposeHandle(hdl);
}