void sort_list(Att_List *input_list) { struct Node *node,*tmpnode,*next_node; struct List *list,sorted; list=&input_list->list; if (list && !IsListEmpty(list)) { NewList(&sorted); while ((node=(struct Node*)(list->lh_Head)) && list->lh_Head->ln_Succ!=NULL) /* list not empty!*/ { tmpnode=node; while ((next_node=node->ln_Succ)) { if (stricmp(tmpnode->ln_Name,node->ln_Name)>0) tmpnode=node; node=next_node; } Remove(tmpnode); AddTail(&sorted,tmpnode); } while ((node=sorted.lh_Head) && sorted.lh_Head->ln_Succ!=NULL) /* list not empty!*/ { Remove(node); AddTail(list,node); } } }
void CPTRList::InsertAfter( int n,void *pData) { if ( n<0 ) { AddTail(pData); return ; } if ( n==GetCount()-1) { AddTail(pData); return; } GetAt(n); nCurrent = -1; PTR_BLK *pNew = new PTR_BLK; pNew->pData = pData; pNew->pPrev = pCur; pNew->pNext = pCur->pNext; pCur->pNext->pPrev = pNew; pCur->pNext = pNew; nMax++; }
DWORD LStrList::LoadFromFile(LTxtFile* tf, BOOL bIncludeNull) { LAutoLock al(m_lock); // 如果列表为空,则按照来源文件编码 if (LPtrList::IsEmpty()) { m_dwFlags = 0; if (tf->IsUnicode()) { m_dwFlags = SLFLAG_UNICODE; m_pfnCopy = LStrList_CopyW; m_pfnDestroy = LStrList_DestroyW; } else { m_pfnCopy = LStrList_CopyA; m_pfnDestroy = LStrList_DestroyA; } } DWORD ret = 0; if (IsUnicode()) { LStringW str; while (!tf->Eof()) { tf->ReadLn(&str); if ((L'\0' != str[0]) || bIncludeNull) { AddTail(str); ++ret; } } } else { LStringA str; while (!tf->Eof()) { tf->ReadLn(&str); if (('\0' != str[0]) || bIncludeNull) { AddTail(str); ++ret; } } } return ret; }
void CStringList::Serialize(CArchive& ar) { ASSERT_VALID(this); CObject::Serialize(ar); if (ar.IsStoring()) { ar << (WORD) m_nCount; for (CNode* pNode = m_pNodeHead; pNode != NULL; pNode = pNode->pNext) { ASSERT(AfxIsValidAddress(pNode, sizeof(CNode))); ar << pNode->data; } } else { WORD nNewCount; ar >> nNewCount; CString newData; while (nNewCount--) { ar >> newData; AddTail(newData); } } }
static bool URLHistoryFound(const char *url, const struct url_data *data) { struct Node *node; /* skip this URL if it is already in the list */ if(URLHistory_FindPage(url)) return true; node = AllocVec( sizeof( struct Node ), MEMF_SHARED|MEMF_CLEAR ); if ( node ) { STRPTR urladd = (STRPTR) AllocVec( strlen ( url ) + 1, MEMF_SHARED|MEMF_CLEAR ); if ( urladd ) { strcpy(urladd, url); node->ln_Name = urladd; AddTail( &PageList, node ); } else { FreeVec(node); } } return true; }
/// /// _MEMTRACK // add a new node to the memory tracking lists void _MEMTRACK(const char *file, const int line, const char *func, void *ptr, size_t size) { if(isFlagSet(debug_classes, DBC_MTRACK)) { if(ptr != NULL && size != 0) { struct DbgMallocNode *dmn; if((dmn = AllocVec(sizeof(*dmn), MEMF_ANY)) != NULL) { dmn->memory = ptr; dmn->size = size; dmn->file = file; dmn->line = line; dmn->func = func; ObtainSemaphore(&DbgMallocListSema); AddTail((struct List *)&DbgMallocList[ptr2hash(ptr)], (struct Node *)&dmn->node); DbgMallocCount++; ReleaseSemaphore(&DbgMallocListSema); } } else _DPRINTF(DBC_WARNING, DBF_ALWAYS, file, line, "potential invalid %s call with return (0x%08lx, 0x%08lx)", func, ptr, size); } }
CRecord CRecord::operator =(ARFieldValueList &fieldList) { ARFieldValueStruct *pFieldValuePair = fieldList.fieldValueList; // working pointer CFieldValuePair FieldValuePair; // working field value pair CString workingString; // working string to convert value // Loop once for each field/value pair in the list for(UINT i=0; i<fieldList.numItems; i++, pFieldValuePair++) { // decode the field/value pair FieldValuePair.uiFieldId = pFieldValuePair->fieldId; // save field id FieldValuePair.uiType = pFieldValuePair->value.dataType; // save data type switch(pFieldValuePair->value.dataType) // convert the value based on data type { case AR_DATA_TYPE_NULL: workingString.Empty(); break; case AR_DATA_TYPE_INTEGER: case AR_DATA_TYPE_TIME: case AR_DATA_TYPE_DATE: case AR_DATA_TYPE_TIME_OF_DAY: case AR_DATA_TYPE_KEYWORD: case AR_DATA_TYPE_BITMASK: workingString.Format("%d", pFieldValuePair->value.u.intVal); break; case AR_DATA_TYPE_REAL: workingString.Format("%e", pFieldValuePair->value.u.realVal); break; case AR_DATA_TYPE_CHAR: case AR_DATA_TYPE_DIARY: case AR_DATA_TYPE_DECIMAL: workingString = pFieldValuePair->value.u.charVal; break; case AR_DATA_TYPE_ENUM: workingString.Format("%u", pFieldValuePair->value.u.enumVal); break; case AR_DATA_TYPE_ATTACH: workingString = FieldValuePair.StoreAttachment(pFieldValuePair->value.u.attachVal); break; case AR_DATA_TYPE_CURRENCY: workingString = FieldValuePair.StoreCurrency(pFieldValuePair->fieldId, pFieldValuePair->value.u.currencyVal); break; default: workingString.Empty(); ThrowARSException(UNKNOWN_DATA_TYPE, "CRecord::operator=()"); break; } // end switch // decode attachement fields // decode currency fields FieldValuePair.Value = workingString; // save the decoded value AddTail(FieldValuePair); // Add the field/value pair } // end for // return the populated record return *this; }
void CObList::Serialize(CArchive& ar) { ASSERT_VALID(this); CObject::Serialize(ar); if (ar.IsStoring()) { ar.WriteCount(m_nCount); for (CNode* pNode = m_pNodeHead; pNode != NULL; pNode = pNode->pNext) { ASSERT(AfxIsValidAddress(pNode, sizeof(CNode))); ar << pNode->data; } } else { DWORD_PTR nNewCount = ar.ReadCount(); CObject* newData; while (nNewCount--) { ar >> newData; AddTail(newData); } } }
/** * * Add a filename to a list. * **/ void addfile(char *name) { FileNode *filenode = (FileNode *)malloc(sizeof(FileNode) + strlen(name)); strcpy(filenode->name, name); AddTail(&filelist, &filenode->node); }
void LIBFUNC L_AddSorted( REG(a0, struct List *list), REG(a1, struct Node *node)) { struct Node *posnode,*lastnode=0; BOOL added=0; // Go through existing nodes for (posnode=list->lh_Head; posnode->ln_Succ; lastnode=posnode,posnode=posnode->ln_Succ) { // Compare new node name against existing name if ((stricmp(node->ln_Name,posnode->ln_Name))<=0) { // Insert into list Insert(list,node,lastnode); added=1; break; } } // If not added, add to end of list if (!added) AddTail(list,node); }
BOOL GlobalFractalList::AddFractal(FillGeometryAttribute* NewFractal) { CachedFractal* ExistingFrac = CheckFractalBitmap(NewFractal); if (ExistingFrac != NULL) { ExistingFrac->IncUsageCount(); return FALSE; } CachedFractal* Fractal = new CachedFractal(); if (Fractal == NULL) return FALSE; TRACEUSER( "Mike", _T("Adding Cached Fractal @ %x\n"),Fractal); Fractal->SetCachedFractal(NewFractal); Fractal->IncUsageCount(); AddTail((ListItem*)Fractal); if (this != GetApplication()->GetGlobalFractalList()) Fractal->MakeFakeFractal(); TRACEUSER( "Mike", _T("Cached Fractal Count = %d\n"),GetFractalCacheCount()); TRACEUSER( "Mike", _T("Cached Fractal Size = %d\n"),GetFractalCacheSize()); return(TRUE); }
CFormList & CFormList::operator =(CFormList &newList) { RemoveAll(); AddTail(&newList); return *this; }
///////////////////////////////////////////////////////////////////// // Fills the list with all the form names on the server void CFormList::GetForms(CARSConnection &arsConnection, unsigned int uiType) { ARStatusList statusList; ARNameList nameList; // list of form names ARNameType *pNameType; // pointer to a single form name unsigned int i = 0; // get the list of form names if(ARGetListSchema(&arsConnection.LoginInfo, 0, // change since uiType, // form type to get NULL, // name of uplink/downlink form NULL, // id list of fields to qualify forms retrieved &nameList, // return value, the list of form names &statusList) > AR_RETURN_OK) { FreeARNameList(&nameList, FALSE); ThrowARSException(statusList, "CFormList::GetForms()"); } FreeARStatusList(&statusList, FALSE); CString strFormName; for(i=0, pNameType = nameList.nameList; i < nameList.numItems; i++, pNameType++) { strFormName = (char*)pNameType; AddTail(strFormName); } // Free heap memory FreeARNameList(&nameList, FALSE); }
// Add PopUp extensions void add_popup_ext(char *menu,Att_List *type_list,char *command,ULONG flags) { Att_Node *node; // Go through menu list for (node=(Att_Node *)type_list->list.lh_Head; node->node.ln_Succ; node=(Att_Node *)node->node.ln_Succ) { Cfg_Filetype *ftype=0; ULONG type=0; short a; // No name? if (!node->node.ln_Name) continue; // Special type? for (a=0;icon_types[a];a++) { // Compare string if (stricmp(node->node.ln_Name,icon_types[a])==0) { // All? if (a==0) type=POPUP_ALL; else type=a; break; } } // Search filetypes? if (!type) { // Try to find filetype if (!(ftype=filetype_find(node->node.ln_Name,1))) ftype=filetype_find(node->node.ln_Name,0); } // Got something to match on? if (type || ftype) { PopUpExt *ext; // Allocate PopUpExtension if ((ext=AllocMemH(global_memory_pool,sizeof(PopUpExt)))) { // Fill it out ext->pe_Type=type; if (ftype) stccpy(ext->pe_FileType,ftype->type.name,sizeof(ext->pe_FileType)); stccpy(ext->pe_Command,command,40); stccpy(ext->pe_Menu,menu,40); ext->pe_Flags=flags; // Lock list and add new entry lock_listlock(&GUI->popupext_list,TRUE); AddTail(&GUI->popupext_list.list,(struct Node *)ext); unlock_listlock(&GUI->popupext_list); } } } }
void gptimer1_handler(int id) { uint32_t irq = reg32r(GPTIMER1_BASE, GPT_TISR); { static int blink = 0; if (blink & (1<<2)) { LEDS_OFF(LED0); LEDS_ON(LED1); } else { LEDS_ON(LED0); LEDS_OFF(LED1); } blink++; } // check for overflow int if (irq & OVF_IT_FLAG) { Remove(&thistask->Node); AddTail(&tasks, &thistask->Node); thistask = (struct task *)tasks.Head; irq_new_task(tcb_to_sp(&thistask->tcb)); } // clear ints reg32w(GPTIMER1_BASE, GPT_TISR, ~0); }
BOOL CPtrListExt :: AddRecord (COleVariant varBookmark, const char *pAbfallArt, BOOL bFirst/* = TRUE*/) { ASSERT (NULL != pAbfallArt && AfxIsValidString (pAbfallArt)); ASSERT (*pAbfallArt); try { CString strArt (pAbfallArt); CRecordInfo *pInfo = new CRecordInfo (strArt, varBookmark); AddTail (pInfo); // ggf. als 1. Satz setzen if (bFirst) return SetFirstRecord (varBookmark); return TRUE; } catch (CDaoException *e) { :: DisplayDaoException (e); e -> Delete (); } catch (CException *e) { e -> ReportError (); e -> Delete (); } return FALSE; }
POSITION CPtrList::InsertAfter(POSITION position, void* newElement) { ASSERT_VALID(this); if (position == NULL) return AddTail(newElement); // insert after nothing -> tail of the list // Insert it before position CNode* pOldNode = (CNode*) position; ASSERT(AfxIsValidAddress(pOldNode, sizeof(CNode))); CNode* pNewNode = NewNode(pOldNode, pOldNode->pNext); pNewNode->data = newElement; if (pOldNode->pNext != NULL) { ASSERT(AfxIsValidAddress(pOldNode->pNext, sizeof(CNode))); pOldNode->pNext->pPrev = pNewNode; } else { ASSERT(pOldNode == m_pNodeTail); m_pNodeTail = pNewNode; } pOldNode->pNext = pNewNode; return (POSITION) pNewNode; }
BOOL CDRArrowheadStore::AddChunkToStore(RIFFFile *RIFF) { if(RIFF->GetObjType() != RIFFOBJECTTYPE_CHUNK) { ERROR2(FALSE, "CDRAttributeStore::AddChunkToStore called without a chunk in the RIFFFile"); } // get a new item obect CDRArrowheadStoredItem *Item = new CDRArrowheadStoredItem; if(Item == 0) return FALSE; // get the data of the RIFF chunk if(!Item->Aquire(RIFF)) { delete Item; return FALSE; } Item->Size = RIFF->GetObjSize(); // and add the new item to the list AddTail(Item); return TRUE; }
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); }
// Compile function list into function void funced_compile(FuncEdData *data) { FunctionEntry *entry; Cfg_Instruction *ins; Att_Node *node; // Free existing instructions FreeInstructionList(data->function); // Got a label? if (data->label[0]) { // Create label instruction if ((ins=NewInstruction(0,INST_LABEL,data->label))) AddHead((struct List *)&data->function->instructions,(struct Node *)ins); } // Go through instructions for (node=(Att_Node *)data->function_list->list.lh_Head; node->node.ln_Succ; node=(Att_Node *)node->node.ln_Succ) { // Get function entry entry=(FunctionEntry *)node->data; // Create a new instruction if ((ins=NewInstruction(0,entry->type,entry->buffer))) { // Add to function list AddTail((struct List *)&data->function->instructions,(struct Node *)ins); } } }
void CPacketQueue::Add(CAutoPtr<Packet> p) { CAutoLock cAutoLock(this); if(p) { m_size += p->GetDataSize(); if(p->bAppendable && !p->bDiscontinuity && !p->pmt && p->rtStart == Packet::INVALID_TIME && !IsEmpty() && GetTail()->rtStart != Packet::INVALID_TIME) { Packet* tail = GetTail(); int oldsize = tail->GetCount(); int newsize = tail->GetCount() + p->GetCount(); tail->SetCount(newsize, max(1024, newsize)); // doubles the reserved buffer size memcpy(tail->GetData() + oldsize, p->GetData(), p->GetCount()); /* GetTail()->Append(*p); // too slow */ return; } } AddTail(p); }
BOOL CreateResouces( struct ResourceIteratorList* ril, struct List* result, struct ISAPNPBase* res ) { // Allocate resources for current iterators struct ResourceIterator* iter; for( iter = (struct ResourceIterator*) ril->m_ResourceIterators.mlh_Head; iter->m_MinNode.mln_Succ != NULL; iter = (struct ResourceIterator*) iter->m_MinNode.mln_Succ ) { struct ISAPNP_Resource* resource; resource = CreateResource( iter, res ); if( resource == NULL ) { return FALSE; } AddTail( result, (struct Node*) resource ); } return TRUE; }
/////////////////////////////////////////////////////////////////// // CChartList::Open // This reads in records from the file YY\chart // BOOL CChartList::Open(const char* pszChartFileName) { const int SZCHARTLINE = 80; char ChartInputRecord[SZCHARTLINE+1]; CChart c; BOOL bGOOD_INPUT; ASSERT_VALID( this ); int rec_cnt = 0; CStdioFile cf( pszChartFileName, CFile::modeRead ); while ( cf.ReadString( ChartInputRecord, SZCHARTLINE ) ) { bGOOD_INPUT = c.Convert( ChartInputRecord ); if( bGOOD_INPUT ) { AddTail( new CChart( c ) ); } } cf.Close(); return TRUE; }
struct MidiCluster *NewCluster(char *name,struct CamdBase *CamdBase){ struct MyMidiCluster *mymidicluster; struct MidiCluster *midicluster; mymidicluster=AllocMem(sizeof(struct MyMidiCluster),MEMF_ANY | MEMF_CLEAR | MEMF_PUBLIC); if(mymidicluster==NULL) return NULL; InitSemaphore(&mymidicluster->semaphore); midicluster=&mymidicluster->cluster; midicluster->mcl_Node.ln_Name=AllocVec(mystrlen(name) + 1,MEMF_ANY|MEMF_PUBLIC); if(midicluster->mcl_Node.ln_Name==NULL){ FreeMem(midicluster,sizeof(struct MyMidiCluster)); return NULL; } mysprintf(CamdBase,midicluster->mcl_Node.ln_Name,"%s",name); NEWLIST(&midicluster->mcl_Receivers); NEWLIST(&midicluster->mcl_Senders); AddTail(&CB(CamdBase)->midiclusters,&midicluster->mcl_Node); return midicluster; }
AUI_ERRCODE aui_DirtyList::AddRect( sint32 left, sint32 top, sint32 right, sint32 bottom ) { if ( left < right && top < bottom ) { RECT *rect = m_rectMemory->New(); Assert( rect != NULL ); if ( !rect ) return AUI_ERRCODE_MEMALLOCFAILED; rect->left = left; rect->top = top; rect->right = right; rect->bottom = bottom; AddTail( rect ); if ( m_spanListArray ) ComputeSpans( rect ); } return AUI_ERRCODE_OK; }
static int thylacine_Init(struct ThylacineBase *tb) { struct Library *ExpansionBase; int unit = 0; InitSemaphore(&tb->tb_UnitLock); NEWLIST(&tb->tb_Units); if ((ExpansionBase = OpenLibrary("expansion.library", 36))) { struct ConfigDev *cd = NULL; while ((cd = FindConfigDev(cd, THYLACINE_VENDOR, THYLACINE_PRODUCT))) { struct sl811hs *sl; ULONG addr = (ULONG)(IPTR)cd->cd_BoardAddr; ULONG data = addr + 0x4000; // ULONG reset = addr + 0x100; sl = sl811hs_Attach(addr, data, INTB_EXTER); if (sl) { ((struct Node *)sl)->ln_Pri = unit++; ((struct Node *)sl)->ln_Name = "thylacine.device"; AddTail(&tb->tb_Units, (struct Node *)sl); } } CloseLibrary(ExpansionBase); } return IsListEmpty(&tb->tb_Units) ? 0 : 1; }
bool CMyArray::Insert(int nIndex, int newElem) { assert(nIndex >= 0); assert(nIndex < m_nLength); if (m_pData == NULL) { AddTail(newElem); return true; } //空间不够 else if (m_nLength >= m_nSize) { Alloc(m_nSize, m_nSize * 2); } //移动元素 // memmove(m_pData + nIndex + 1, // m_pData + nIndex, // (m_nLength - nIndex) * sizeof(int)); for (int i = m_nLength; i > nIndex; i--) { m_pData[i] = m_pData[i - 1]; } m_pData[nIndex] = newElem; m_nLength++; return true; }
LIBFUNC1(void, Reschedule, struct Task *, task, struct ExecBase *,SysBase) { switch(task->tc_State) { case TS_READY: Enqueue(&SysBase->TaskReady, (struct Node *)task); break; case TS_ADDED: Enqueue(&SysBase->TaskReady, (struct Node *)task); break; case TS_WAIT: AddTail(&SysBase->TaskWait, (struct Node *)task); break; case TS_REMOVED: /* Ideally we should free the task here, but we can't because that would corrupt the memory lists. */ break; case TS_INVALID: case TS_EXCEPT: case TS_RUN: /* We should never be called with this state. */ break; } }
void CPTRList::InsertBefore( int n,void *pData) { if ( n<0 ) { AddTail(pData); return; } if ( n==0 ) { AddHead(pData); return ; } GetAt(n); nCurrent = -1; PTR_BLK *pNew = new PTR_BLK; pNew->pData = pData; pNew->pPrev = pCur->pPrev; pNew->pNext = pCur; pCur->pPrev->pNext = pNew; pCur->pPrev = pNew; nMax++; }
/*============================================================================= *NAME :TYSIniFile::Add : *MODULE :YSIniFiles.cpp : *FUNCTION :追加処理関数です : *PROCESS :・追加処理です。 : *RETURN :追加クラス : *PROGRAMMED :Y.Sasai *HISTORY : *ID -- DATE ------- NOTE ------------------------------------------------------ *00 03.02.10 Y.Sasai Ver.0.90 初期作成 */ TYSIniSection* TYSIniFile::Add( void ) { TYSIniSection* result = new TYSIniSection(); // 2003.02.10 Y.Sasai Ver.0.90 新規のセクションクラス作成 AddTail( result ); // 2003.02.10 Y.Sasai Ver.0.90 追加だ return ( result ); // 2003.02.10 Y.Sasai Ver.0.90 おわりだ }