Fix IORequest duplication and ensure library bases are cleared when closed.

This commit is contained in:
Chris Young 2019-03-17 23:43:47 +00:00
parent 7d402ebc46
commit d0a9fc3e35
2 changed files with 16 additions and 4 deletions

View File

@ -113,7 +113,9 @@
#define AMINS_CLASS_CLOSE(PREFIX) \
if(I##PREFIX) DropInterface((struct Interface *)I##PREFIX); \
if(PREFIX##Base) CloseClass(PREFIX##Base);
if(PREFIX##Base) CloseClass(PREFIX##Base); \
I##PREFIX = NULL; \
PREFIX##Base = NULL;
#define AMINS_CLASS_STRUCT(PREFIX) \
struct ClassLibrary *PREFIX##Base = NULL; \
@ -136,7 +138,8 @@
}
#define AMINS_LIB_CLOSE(PREFIX) \
if(PREFIX##Base) CloseLibrary((struct Library *)PREFIX##Base);
if(PREFIX##Base) CloseLibrary((struct Library *)PREFIX##Base); \
PREFIX##Base = NULL;
#define AMINS_LIB_STRUCT(PREFIX) \
struct PREFIX##Base *PREFIX##Base = NULL;
@ -156,7 +159,8 @@
}
#define AMINS_CLASS_CLOSE(PREFIX) \
if(PREFIX##Base) CloseLibrary(PREFIX##Base);
if(PREFIX##Base) CloseLibrary(PREFIX##Base); \
PREFIX##Base = NULL;
#define AMINS_CLASS_STRUCT(PREFIX) \
struct Library *PREFIX##Base = NULL; \

View File

@ -170,7 +170,11 @@ static nserror schedule_remove(void (*callback)(void *p), void *p, bool abort)
if(nscb != NULL) {
if(abort == true) ami_schedule_remove_timer_event(nscb);
#ifdef __amigaos4__
FreeSysObject(ASOT_IOREQUEST, nscb);
#else
FreeVec(nscb);
#endif
pblHeapConstruct(schedule_list);
}
@ -190,7 +194,11 @@ static void schedule_remove_all(void)
{
ami_schedule_remove_timer_event(nscb);
pblIteratorRemove(iterator);
#ifdef __amigaos4__
FreeSysObject(ASOT_IOREQUEST, nscb);
#else
FreeVec(nscb);
#endif
};
pblIteratorFree(iterator);
@ -337,7 +345,7 @@ nserror ami_schedule(int t, void (*callback)(void *p), void *p)
TAG_DONE);
#else
if(schedule_msgport == NULL) return NSERROR_NOMEM;
nscb = (struct nscallback *)CreateIORequest(schedule_msgport, sizeof(struct nscallback));
nscb = AllocVec(sizeof(struct nscallback), MEMF_PUBLIC | MEMF_CLEAR);
*nscb = *tioreq;
#endif
if(!nscb) return NSERROR_NOMEM;