1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox Host Guest Shared Memory Interface (HGSMI).
|
---|
4 | * Host part helpers.
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2010 Oracle Corporation
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | */
|
---|
18 |
|
---|
19 |
|
---|
20 | #include "HGSMIHostHlp.h"
|
---|
21 |
|
---|
22 |
|
---|
23 | void hgsmiListAppend (HGSMILIST *pList, HGSMILISTENTRY *pEntry)
|
---|
24 | {
|
---|
25 | AssertPtr(pEntry);
|
---|
26 | Assert(pEntry->pNext == NULL);
|
---|
27 |
|
---|
28 | if (pList->pTail)
|
---|
29 | {
|
---|
30 | Assert (pList->pTail->pNext == NULL);
|
---|
31 | pList->pTail->pNext = pEntry;
|
---|
32 | }
|
---|
33 | else
|
---|
34 | {
|
---|
35 | Assert (pList->pHead == NULL);
|
---|
36 | pList->pHead = pEntry;
|
---|
37 | }
|
---|
38 |
|
---|
39 | pList->pTail = pEntry;
|
---|
40 | }
|
---|
41 |
|
---|
42 |
|
---|
43 | void hgsmiListRemove (HGSMILIST *pList, HGSMILISTENTRY *pEntry, HGSMILISTENTRY *pPrev)
|
---|
44 | {
|
---|
45 | AssertPtr(pEntry);
|
---|
46 |
|
---|
47 | if (pEntry->pNext == NULL)
|
---|
48 | {
|
---|
49 | Assert (pList->pTail == pEntry);
|
---|
50 | pList->pTail = pPrev;
|
---|
51 | }
|
---|
52 | else
|
---|
53 | {
|
---|
54 | /* Do nothing. The *pTail is not changed. */
|
---|
55 | }
|
---|
56 |
|
---|
57 | if (pPrev == NULL)
|
---|
58 | {
|
---|
59 | Assert (pList->pHead == pEntry);
|
---|
60 | pList->pHead = pEntry->pNext;
|
---|
61 | }
|
---|
62 | else
|
---|
63 | {
|
---|
64 | pPrev->pNext = pEntry->pNext;
|
---|
65 | }
|
---|
66 |
|
---|
67 | pEntry->pNext = NULL;
|
---|
68 | }
|
---|
69 |
|
---|
70 | HGSMILISTENTRY * hgsmiListRemoveAll (HGSMILIST *pList, HGSMILISTENTRY ** ppTail /* optional */)
|
---|
71 | {
|
---|
72 | HGSMILISTENTRY * pHead = pList->pHead;
|
---|
73 | if (ppTail)
|
---|
74 | *ppTail = pList->pTail;
|
---|
75 |
|
---|
76 | hgsmiListInit (pList);
|
---|
77 |
|
---|
78 | return pHead;
|
---|
79 | }
|
---|
80 |
|
---|