void RethinkPlayers ( struct AHIDevUnit *iounit, struct AHIBase *AHIBase ) { struct MinList templist; struct AHIRequest *ioreq; NewList((struct List *) &templist); ObtainSemaphore(&iounit->ListLock); RemPlayers((struct List *) &iounit->PlayingList, iounit, AHIBase); RemPlayers((struct List *) &iounit->SilentList, iounit, AHIBase); // Move all silent requests to our temporary list while((ioreq = (struct AHIRequest *) RemHead((struct List *) &iounit->SilentList))) { AddTail((struct List *) &templist, (struct Node *) ioreq); } // And add them back... while((ioreq = (struct AHIRequest *) RemHead((struct List *) &templist))) { AddWriter(ioreq, iounit, AHIBase); } ReleaseSemaphore(&iounit->ListLock); }
void FreeList(struct List *list) { struct Node *n; if(list == NULL) return; for( n = RemHead(list); n != NULL; n = RemHead(list) ) { FreeVec(n); } FreeVec(list); }
MoveInfo *moveInfoAlloc( void ) { MoveInfo *theMoveInfo; if( IsListEmpty( &FreeMoveInfos )) { if( theMoveInfo = AllocMem( sizeof( MoveInfo ), MEMF_CLEAR )) { NewList( &theMoveInfo->mi_Moves ); if(!( theMoveInfo->mi_Stacks = AllocMem( sizeof( Stack )*boardNumStacks(), MEMF_CLEAR ))) { moveInfoReallyFree( theMoveInfo ); return 0L; } } } else { theMoveInfo = ( MoveInfo * )RemHead( &FreeMoveInfos ); theMoveInfo->mi_SrcStack = 0; theMoveInfo->mi_DestStack = 0; theMoveInfo->mi_Parent = 0L; } return theMoveInfo; }
void rexxrecbinfile(struct RexxMsg *mess) { char buf[1024]; struct TransferFiles *tf; Servermem->action[nodnr] = UPLOAD; Servermem->varmote[nodnr] = 0; Servermem->vilkastr[nodnr] = NULL; if(recbinfile(hittaefter(mess->rm_Args[0]))) strcpy(buf,"0"); else { buf[0] = NULL; for(tf=(struct TransferFiles *)tf_list.mlh_Head;tf->node.mln_Succ;tf=(struct TransferFiles *)tf->node.mln_Succ) { strcat(buf,FilePart(tf->Filnamn)); strcat(buf,(char *)" "); } buf[strlen(buf)-1] = NULL; } while(tf=(struct TransferFiles *)RemHead((struct List *)&tf_list)) FreeMem(tf,sizeof(struct TransferFiles)); if(mess->rm_Action & 1L<<RXFB_RESULT) { if(!(mess->rm_Result2=(long)CreateArgstring(buf,strlen(buf)))) puttekn("\r\n\nKunde inte allokera en Argstring!\r\n\n",-1); } }
void moveInfoClassDestruct( void *Dummy ) { MoveInfo *aMoveInfo; while( aMoveInfo = ( MoveInfo * )RemHead( &FreeMoveInfos )) moveInfoReallyFree( aMoveInfo ); }
BOOL FreeResourceIteratorList( struct ResourceIteratorList* list, struct ResourceContext* ctx ) { BOOL rc = FALSE; struct ResourceIterator* iter; #ifdef DEBUG_ITERATORS KPrintF( "FreeResourceIteratorList()\n" ); #endif if( list == NULL ) { return FALSE; } while( ( iter = (struct ResourceIterator*) RemHead( (struct List*) &list->m_ResourceIterators ) ) ) { if( FreeResourceIterator( iter, ctx ) ) { rc = TRUE; } } FreeVec( list ); #ifdef DEBUG_ITERATORS if( rc ) KPrintF( "FreeResourceIteratorList() T\n" ); else KPrintF( "FreeResourceIteratorList() F\n" ); #endif return rc; }
TurbulanceList::~TurbulanceList() { // this will clean up any stray objects on exit AircraftTurbulence *at; while(at = (AircraftTurbulence *)RemHead()) delete at; }
/* * The Reader process simply waits for a request to arrive and then * reads a message from the /ether server. * It calls the Action routine, so the stack size here must be adequate * for the tcpip server to do its packet arrival processing. */ static void Reader( NetDCB * dcb ) { word got; NetDevReq * req; for (;;) { /* wait for a request from server */ Wait( &dcb->nreq ); /* remove it from list. Note that we must lock the DCB */ /* before doing this. */ Wait( &dcb->lock ); req = (NetDevReq *)RemHead( &dcb->readq ); Signal( &dcb->lock ); if (req == NULL) continue; /* Read until we get some data, we hope that it will */ /* be a complete ether packet. */ again: got = Read( dcb->read, (char *) req->Buf, req->Size, -1 ); if (got <= 0) { #ifdef DEBUG IOdebug( "Reader: Read failed, return code = %d, Result2 = %x", got, Result2( dcb->read ) ); #endif goto again; } #ifdef DEBUG { int i; char * buf = (char *)req->Buf; IOdebug( "RX %d [%", got ); for (i = 0;i < 24; i++) IOdebug( "%x %", buf[ i ] ); IOdebug( "]" ); } #endif req->Actual = got; req->DevReq.Result = 0; /* Return request to server. */ (*req->DevReq.Action)( dcb, req ); } return; } /* Reader */
void UnInitC(void) { Node *node; while (node = RemHead(&StrList)) FreeMem(node, sizeof(Node) + strlen(node->ln_Name) + 1); }
void cleanup(void) { int i; for(i = 0;i < 2;i++) while((node = RemHead(&list[i])) != 0) FreeMem(node,sizeof(struct Node)); }
void freegroupmem(void) { struct UserGroup *pekare; while(Servermem->grupp_list.mlh_Head->mln_Succ) { pekare=(struct UserGroup *)Servermem->grupp_list.mlh_Head; RemHead((struct List *)&Servermem->grupp_list); FreeMem(pekare,sizeof(struct UserGroup)); } }
void freeshortusermem(void) { struct ShortUser *pekare; while(Servermem->user_list.mlh_Head->mln_Succ) { pekare=(struct ShortUser *)Servermem->user_list.mlh_Head; RemHead((struct List *)&Servermem->user_list); FreeMem(pekare,sizeof(struct ShortUser)); } }
void moveInfoFree( MoveInfo *theMoveInfo ) { Move *aMove; while( aMove = ( Move * )RemHead( &theMoveInfo->mi_Moves )) moveFree( aMove ); AddHead( &FreeMoveInfos, ( struct Node * )theMoveInfo ); }
static int thylacine_Expunge(struct ThylacineBase *tb) { struct sl811hs *sl; while ((sl = (struct sl811hs *)RemHead(&tb->tb_Units))) sl811hs_Detach(sl); return 1; }
void URLHistory_ClearList( void ) { struct Node *node; while(( node = RemHead( &PageList ))) { if( node->ln_Name) FreeVec( node->ln_Name ); FreeVec( node ); } }
void FreeISAPNPBase( struct ISAPNPBase* res ) { struct ISAPNP_Card* card; while( ( card = (struct ISAPNP_Card*) RemHead( &res->m_Cards ) ) ) { ISAPNP_FreeCard( card, ISAPNPBase ); } }
void freefilemem(void) { int x; struct Fil *pekare; for(x=0;x<MAXAREA;x++) { while(Servermem->areor[x].ar_list.mlh_Head->mln_Succ) { pekare=(struct Fil *)Servermem->areor[x].ar_list.mlh_Head; RemHead((struct List *)&Servermem->areor[x].ar_list); FreeMem(pekare,sizeof(struct Fil)); } } }
void ResetReloc(void) { RelocInfo *r; if (RelList.lh_Head == NULL) cerror(EFATAL, "Software Error, ResetReloc"); while ((r = RemHead(&RelList)) != NULL) free(r); RelOffCache = NULL; }
VOID FreeBlankerEntries( struct List *Entries ) { BlankerEntry *FreeMe; if( !Entries ) return; while( FreeMe = ( BlankerEntry * )RemHead( Entries )) FreeVec( FreeMe ); FreeVec( Entries ); }
// Add an entry to the OpenWith file void add_open_with(char *line) { APTR file; struct Node *node; // Lock list lock_listlock(&GUI->open_with_list,1); // Too many nodes? if (Att_NodeCount((Att_List *)&GUI->open_with_list)>=environment->env->settings.max_openwith) { // List is empty? if (IsListEmpty((struct List *)&GUI->open_with_list.list)) return; // Get first node node=GUI->open_with_list.list.lh_Head; // Remove first node and free it RemHead((struct List *)&GUI->open_with_list); FreeMemH(node); } // Allocate a new node if (node=AllocMemH(global_memory_pool,sizeof(struct Node)+strlen(line)+1)) { // Initialise node and copy string node->ln_Name=(char *)(node+1); strcpy(node->ln_Name,line); // Add to Open With list AddTail((struct List *)&GUI->open_with_list,node); } // Open file for output if (file=OpenBuf("DOpus5:System/OpenWith",MODE_NEWFILE,4000)) { // Write lines for (node=GUI->open_with_list.list.lh_Head;node->ln_Succ;node=node->ln_Succ) { // Write line WriteBuf(file,node->ln_Name,strlen(node->ln_Name)); WriteBuf(file,"\n",1); } // Close file CloseBuf(file); } // Unlock list unlock_listlock(&GUI->open_with_list); }
void moveInfoReallyFree( MoveInfo *theMoveInfo ) { Move *aMove; if( theMoveInfo ) { while( aMove = ( Move * )RemHead( &theMoveInfo->mi_Moves )) moveFree( aMove ); if( theMoveInfo->mi_Stacks ) FreeMem( theMoveInfo->mi_Stacks, sizeof( Stack )*boardNumStacks()); FreeMem( theMoveInfo, sizeof( MoveInfo )); } }
AROS_LIBFUNC_INIT #else void FbxCleanupFS( REG(a0, struct FbxFS * fs), REG(a6, struct FileSysBoxBase *libBase)) { #endif ADEBUGF("FbxCleanupFS(%#p)\n", fs); if (fs != NULL) { struct Library *SysBase = fs->sysbase; struct MinNode *chain; // clear msgport in device node. if (fs->devnode != NULL) fs->devnode->dn_Task = NULL; // doslist process if (fs->dlproc_port != NULL) { ObtainSemaphore(&libBase->dlproc_sem); if (--libBase->dlproc_refcount == 0) Signal(&libBase->dlproc->pr_Task, SIGBREAKF_CTRL_C); ReleaseSemaphore(&libBase->dlproc_sem); } while ((chain = (struct MinNode *)RemHead((struct List *)&fs->timercallbacklist)) != NULL) { FreeFbxTimerCallbackData(fs, FSTIMERCALLBACKDATAFROMFSCHAIN(chain)); } if (fs->fsflags & FBXF_ENABLE_DISK_CHANGE_DETECTION) { FbxRemDiskChangeHandler(fs); } DeleteMsgPort(fs->fsport); DeleteMsgPort(fs->notifyreplyport); FreeSignal(fs->diskchangesig); FreeSignal(fs->dbgflagssig); DeletePool(fs->mempool); FbxCleanupTimerIO(fs); FreeFbxFS(fs); } ADEBUGF("FbxCleanupFS: DONE\n"); #ifdef __AROS__ AROS_LIBFUNC_EXIT #endif }
// Free a keyword list. void KeywordEdit::FreeKeyList( LPKEYLIST pKeyList ) { // Iterate the nodes. LPKEYWORDS pKey; while (( pKey = ( LPKEYWORDS )RemHead(( LPLIST )pKeyList )) != NULL ) { // Free the array. if ( pKey->lpaKeywords ) ::ArrayDelete( pKey->lpaKeywords ); // And the node. ::FreePooled( pParserPool, pKey ); } }
VOID LibDeletePool ( /* SYNOPSIS */ APTR pool) /* FUNCTION INPUTS RESULT NOTES EXAMPLE BUGS SEE ALSO INTERNALS HISTORY 06.12.96 digulla Created after original from libnix ******************************************************************************/ { # define poolHeader ((POOL*)pool) if (SysBase->LibNode.lib_Version>=39) DeletePool(poolHeader); else { if (poolHeader != NULL) { ULONG * poolMem, size; while ((poolMem = (ULONG *)RemHead ( (struct List *)&poolHeader->PuddleList) )!=NULL ) { size = *--poolMem; FreeMem (poolMem, size); } FreeMem (poolHeader, sizeof (POOL)); } } } /* LibDeletePool */
packet_t *pkt_tx_alloc(void) { packet_t *p = NULL; ObtainSemaphore(&tx_sem); if(!IsListEmpty(&tx_free)) { p = (packet_t *)RemHead(&tx_free); } ReleaseSemaphore(&tx_sem); if(p!=NULL) { reset_pkt(p); } return p; }
/// /// CleanupDbgMalloc // cleanup the memory tracking framework and output possibly pending allocations static void CleanupDbgMalloc(void) { ENTER(); if(isFlagSet(debug_classes, DBC_MTRACK)) { _DBPRINTF("** Cleaning up memory tracking *************************************\n"); ObtainSemaphore(&DbgMallocListSema); if(DbgMallocCount != 0 || DbgUnsuitableFreeCount != 0) { if(DbgMallocCount != 0) { ULONG i; E(DBF_ALWAYS, "there are still %ld unfreed memory trackings", DbgMallocCount); for(i = 0; i < ARRAY_SIZE(DbgMallocList); i++) { struct DbgMallocNode *dmn; while((dmn = (struct DbgMallocNode *)RemHead((struct List *)&DbgMallocList[i])) != NULL) { _DPRINTF(DBC_ERROR, DBF_ALWAYS, dmn->file, dmn->line, "unfreed memory tracking: 0x%08lx, size/type %ld, func (%s)", dmn->memory, dmn->size, dmn->func); // We only free the node structure here but not dmn->memory itself. // First of all, this is because the allocation could have been done // by other functions than malloc() and calling free() for these will // cause havoc. And second the c-library's startup code will/should // free all further pending allocations upon program termination. FreeVec(dmn); } } } if(DbgUnsuitableFreeCount != 0) { E(DBF_ALWAYS, "there were %ld unsuitable freeing calls", DbgUnsuitableFreeCount); } } else D(DBF_ALWAYS, "all memory trackings have been free()'d correctly"); ReleaseSemaphore(&DbgMallocListSema); } LEAVE(); }
void rexxsendbinfile(struct RexxMsg *mess) { char buf[257],*pek,filtemp[257],tmp[3]; int i,quote; struct TransferFiles *tf; mess->rm_Result1=0; pek=hittaefter(mess->rm_Args[0]); NewList((struct List *)&tf_list); while(pek[0]!=NULL && mess->rm_Result1!=20) { filtemp[0]=NULL; i=0; quote=0; while(pek[0]==' ' && pek[0]!=NULL) pek++; if(pek[0]=='"') { quote=1; pek++; } if(!pek[0]) break; while(((pek[0]!='"' && quote) || (pek[0]!=' ' && !quote)) && pek[0]!=NULL) { filtemp[i++]=pek[0]; pek++; } if(pek[0]=='"') pek++; filtemp[i]=NULL; if(!(tf=(struct TransferFiles *)AllocMem(sizeof(struct TransferFiles),MEMF_CLEAR))) { mess->rm_Result1=20; mess->rm_Result2=NULL; } else { strcpy(tf->path,filtemp); tf->filpek=NULL; AddTail((struct List *)&tf_list,(struct Node *)tf); } } sendbinfile(); buf[0] = NULL; for(tf=(struct TransferFiles *)tf_list.mlh_Head;tf->node.mln_Succ;tf=(struct TransferFiles *)tf->node.mln_Succ) { sprintf(tmp,"%d ",tf->sucess); strcat(buf,tmp); } buf[strlen(buf)-1] = NULL; while(tf=(struct TransferFiles *)RemHead((struct List *)&tf_list)) FreeMem(tf,sizeof(struct TransferFiles)); if(mess->rm_Action & 1L<<RXFB_RESULT) { if(!(mess->rm_Result2=(long)CreateArgstring(buf,strlen(buf)))) puttekn("\r\n\nKunde inte allokera en Argstring!\r\n\n",-1); } }
static void myStringCloseListview( Class *cl, Object *obj ) { struct myStringClassData *data; struct Node *node; data = INST_DATA( cl, obj ); if ( data->Window ) { IDoMethod( data->WindowObject, WM_CLOSE ); data->Window = NULL; } while(( node = RemHead( &data->ListviewHeader ))) { FreeListBrowserNode( node ); } }
void FreeResourceIteratorContext( struct ResourceContext* ctx ) { struct ResourceIteratorRef* ref; if( ctx == NULL ) { return; } while( ( ref = (struct ResourceIteratorRef*) RemHead( (struct List*) &ctx->m_IO ) ) ) { FreeVec( ref ); } FreeVec( ctx ); }
IPTR observerDispose(Class * cl, Object * obj, Msg msg) { IPTR retval; struct ObserverClassData *data; struct FreeNode *fn; data = (struct ObserverClassData *) INST_DATA(cl, obj); fn = (struct FreeNode *) RemHead((struct List *) &data->freeList); while (fn) { FreeVec(fn->f_mem); FreeVec(fn); } retval = DoSuperMethodA(cl, obj, msg); return retval; }