ReactOS 0.4.15-dev-8422-g6219a1a
list.cpp
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS HTTP Daemon
4 * FILE: list.cpp
5 * PURPOSE: A doubly linked list implementation
6 * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
7 * REVISIONS:
8 * CSH 01/09/2000 Created
9 * NOTES: The linked list does it's own heap management for
10 * better performance
11 * TODO: - InsertBefore(), InsertAfter(), Move()
12 */
13#include <windows.h>
14#include <list.h>
15
16// **************************** CListNode ****************************
17
20
21// Default constructor
23{
24 Element = NULL;
25 Next = NULL;
26 Prev = NULL;
27}
28
29// Constructor with element and next as starter values
31{
33 Next = next;
34 Prev = prev;
35}
36
37void* CListNode::operator new(size_t size)
38{
39 PVOID p;
40 if (hHeap == NULL) {
41 SYSTEM_INFO inf;
42 GetSystemInfo(&inf);
43 hHeap = HeapCreate(0, inf.dwAllocationGranularity, 0);
44 }
45 if ((p = HeapAlloc(hHeap, 0, size)) != NULL)
46 nRef++;
47 return p;
48}
49
50VOID CListNode::operator delete(void* p)
51{
52 if (HeapFree(hHeap, 0, p) != FALSE)
53 nRef--;
54 if (nRef == 0) {
55 HeapDestroy(hHeap);
56 hHeap = NULL;
57 }
58}
59
60// Set element
62{
64}
65
66// Set pointer to next node in list
68{
69 Next = next;
70}
71
72// Set pointer to previous node in list
74{
75 Prev = prev;
76}
77
78// Get element of node
80{
81 return Element;
82}
83
84// Get pointer to next node in list
86{
87 return Next;
88}
89
90// Get pointer to previous node in list
92{
93 return Prev;
94}
Definition: list.h:12
CListNode * GetPrev()
Definition: list.cpp:91
VOID SetNext(CListNode *next)
Definition: list.cpp:67
CListNode * Prev
Definition: list.h:29
static HANDLE hHeap
Definition: list.h:30
PVOID Element
Definition: list.h:27
CListNode()
Definition: list.cpp:22
VOID SetElement(PVOID element)
Definition: list.cpp:61
static INT nRef
Definition: list.h:31
VOID SetPrev(CListNode *prev)
Definition: list.cpp:73
CListNode * GetNext()
Definition: list.cpp:85
PVOID GetElement()
Definition: list.cpp:79
CListNode * Next
Definition: list.h:28
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:143
GLsizeiptr size
Definition: glext.h:5919
GLfloat GLfloat p
Definition: glext.h:8902
HANDLE WINAPI HeapCreate(DWORD flOptions, SIZE_T dwInitialSize, SIZE_T dwMaximumSize)
Definition: heapmem.c:45
BOOL WINAPI HeapDestroy(HANDLE hHeap)
Definition: heapmem.c:85
static unsigned __int64 next
Definition: rand_nt.c:6
DWORD dwAllocationGranularity
Definition: winbase.h:1179
int32_t INT
Definition: typedefs.h:58