diff --git a/library/dirent_closedir.c b/library/dirent_closedir.c index d35dc15..c2c2e98 100644 --- a/library/dirent_closedir.c +++ b/library/dirent_closedir.c @@ -125,7 +125,7 @@ CLIB_DESTRUCTOR(dirent_exit) if(__directory_list.mlh_Head != NULL) { - while(NOT IsListEmpty((struct List *)&__directory_list)) + while(NOT IsMinListEmpty(&__directory_list)) closedir((DIR *)__directory_list.mlh_Head); } diff --git a/library/dirent_opendir.c b/library/dirent_opendir.c index 7a0f3a1..6bf644f 100644 --- a/library/dirent_opendir.c +++ b/library/dirent_opendir.c @@ -196,7 +196,7 @@ opendir(const char * path_name) UnLockDosList(LDF_VOLUMES|LDF_READ); /* Bail out if we cannot present anything. */ - if(IsListEmpty((struct List *)&dh->dh_VolumeList)) + if(IsMinListEmpty(&dh->dh_VolumeList)) { __set_errno(ENOMEM); goto out; diff --git a/library/dirent_readdir.c b/library/dirent_readdir.c index ccd984b..d864a5b 100644 --- a/library/dirent_readdir.c +++ b/library/dirent_readdir.c @@ -93,7 +93,7 @@ readdir(DIR * directory_pointer) assert( (((ULONG)name) & 3) == 0 ); - if(dh->dh_VolumeNode == NULL && NOT IsListEmpty((struct List *)&dh->dh_VolumeList)) + if(dh->dh_VolumeNode == NULL && NOT IsMinListEmpty(&dh->dh_VolumeList)) dh->dh_VolumeNode = (struct Node *)dh->dh_VolumeList.mlh_Head; strcpy(name,"\1:"); /* BSTR for ":" */ diff --git a/library/macros.h b/library/macros.h index 39e4556..e1f2c2d 100644 --- a/library/macros.h +++ b/library/macros.h @@ -93,6 +93,13 @@ /****************************************************************************/ +#ifndef IsMinListEmpty +#define IsMinListEmpty(ml) \ + ((struct MinList *)((ml)->mlh_TailPred) == (struct MinList *)(ml)) +#endif + +/****************************************************************************/ + #ifndef AMIGA_COMPILER_H #ifdef __SASC diff --git a/library/stdio_record_locking.c b/library/stdio_record_locking.c index 6f9fec9..ce16619 100644 --- a/library/stdio_record_locking.c +++ b/library/stdio_record_locking.c @@ -327,7 +327,7 @@ remove_locked_region_node(struct FileLockSemaphore * fls,struct fd * fd,LONG sta /* Check if there are any locked regions left. * If not, mark the entire file as unlocked. */ - if(IsListEmpty((struct List *)&which_lock->fln_LockedRegionList)) + if(IsMinListEmpty(&which_lock->fln_LockedRegionList)) { SHOWMSG("no more regions are locked; removing the file lock node"); @@ -705,7 +705,7 @@ cleanup_locked_records(struct fd * fd) } } - if(IsListEmpty((struct List *)&which_lock->fln_LockedRegionList)) + if(IsMinListEmpty(&which_lock->fln_LockedRegionList)) { SHOWMSG("no more regions are locked; removing the file lock node"); diff --git a/library/stdlib_alloca.c b/library/stdlib_alloca.c index e586279..b4ce863 100644 --- a/library/stdlib_alloca.c +++ b/library/stdlib_alloca.c @@ -94,7 +94,7 @@ alloca_cleanup(const char * file,int line) NewList((struct List *)&alloca_memory_list); /* Is this worth cleaning up? */ - if(NOT IsListEmpty((struct List *)&alloca_memory_list)) + if(NOT IsMinListEmpty(&alloca_memory_list)) { struct MemoryContextNode * mcn_prev; struct MemoryContextNode * mcn; @@ -120,7 +120,7 @@ alloca_cleanup(const char * file,int line) /* Drop the cleanup callback if there's nothing to be cleaned up any more. */ - if(IsListEmpty((struct List *)&alloca_memory_list)) + if(IsMinListEmpty(&alloca_memory_list)) __alloca_cleanup = NULL; } diff --git a/library/stdlib_malloc.c b/library/stdlib_malloc.c index 4b0952f..a2eb637 100644 --- a/library/stdlib_malloc.c +++ b/library/stdlib_malloc.c @@ -75,14 +75,15 @@ struct MinList NOCOMMON __memory_list; /****************************************************************************/ void * -__allocate_memory(size_t size,BOOL never_free,const char * UNUSED debug_file_name,int UNUSED debug_line_number) +__allocate_memory(size_t size,BOOL never_free,const char *debug_file_name UNUSED,int debug_line_number UNUSED) { struct MemoryNode * mn; size_t allocation_size; void * result = NULL; - size_t original_size; #if defined(UNIX_PATH_SEMANTICS) + size_t original_size; + { original_size = size; @@ -417,7 +418,7 @@ STDLIB_DESTRUCTOR(stdlib_memory_exit) if(__memory_list.mlh_Head != NULL) { - while(NOT IsListEmpty((struct List *)&__memory_list)) + while(NOT IsMinListEmpty(&__memory_list)) { ((struct MemoryNode *)__memory_list.mlh_Head)->mn_AlreadyFree = FALSE; @@ -453,12 +454,12 @@ STDLIB_DESTRUCTOR(stdlib_memory_exit) { #ifdef __MEM_DEBUG { - while(NOT IsListEmpty((struct List *)&__memory_list)) + while(NOT IsMinListEmpty(&__memory_list)) __free_memory_node((struct MemoryNode *)__memory_list.mlh_Head,__FILE__,__LINE__); } #else { - while(NOT IsListEmpty((struct List *)&__memory_list)) + while(NOT IsMinListEmpty(&__memory_list)) __free_memory_node((struct MemoryNode *)__memory_list.mlh_Head,NULL,0); } #endif /* __MEM_DEBUG */ @@ -478,12 +479,12 @@ STDLIB_DESTRUCTOR(stdlib_memory_exit) { #ifdef __MEM_DEBUG { - while(NOT IsListEmpty((struct List *)&__memory_list)) + while(NOT IsMinListEmpty(&__memory_list)) __free_memory_node((struct MemoryNode *)__memory_list.mlh_Head,__FILE__,__LINE__); } #else { - while(NOT IsListEmpty((struct List *)&__memory_list)) + while(NOT IsMinListEmpty(&__memory_list)) __free_memory_node((struct MemoryNode *)__memory_list.mlh_Head,NULL,0); } #endif /* __MEM_DEBUG */ diff --git a/library/unistd_init_exit.c b/library/unistd_init_exit.c index 88623ef..24db4a5 100644 --- a/library/unistd_init_exit.c +++ b/library/unistd_init_exit.c @@ -69,7 +69,7 @@ CLIB_DESTRUCTOR(unistd_exit) PROFILE_OFF(); - if(__unlink_list.mlh_Head != NULL && NOT IsListEmpty((struct List *)&__unlink_list)) + if(__unlink_list.mlh_Head != NULL && NOT IsMinListEmpty(&__unlink_list)) { struct UnlinkNode * uln; BPTR old_dir;