summaryrefslogtreecommitdiffstats
path: root/private/unimodem/new/mic/ilist.cpp
blob: 64350a621795ef53cd3423cd74c44d9871bfda07 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
//		Copyright (c) 1996 Microsoft Corporation
//
//
//		ILIST.CPP		-- Implementation for Classes:
//							CInfList
//							
//
//		History:
//			05/27/96	JosephJ		Created
//
//
#include "common.h"

///////////////////////////////////////////////////////////////////////////
//		CLASS CInfList
///////////////////////////////////////////////////////////////////////////

//	Simple	singly-linked list which can not be modified once it's been
//  created. Assumes creation and eventual deletion are protected by some
//  external critical section.
//
//	Sample:
//	for (; pList; pList = pList->Next())
//	{
//		const CInfAddregSection *pAS =  (CInfAddregSection *)  pList->GetData();
//	}

//--------------	FreeList		------------------
// Distroys the list.
void
CInfList::FreeList (CInfList *pList)
{
	while(pList)
	{
		// Cast to get rid of the const declaration of pList->Next().
		CInfList *pNext = (CInfList *) pList->Next();
		delete pList;
		pList = pNext;
	}
}

//--------------	ReverseList		------------------
// Reverses the specified list.
void
CInfList::ReverseList (const CInfList **ppList)
{
		CInfList 		*pList = (CInfList *) *ppList; // override const
		const CInfList	*pPrev = NULL;
		while(pList)
		{
			const CInfList *pTmp = pList->Next();
			pList->mfn_SetNext(pPrev);
			pPrev = pList;
			pList = (CInfList *) pTmp; // override const
		}
		*ppList = pPrev;
}