Remove dead code.
[wine.git] / dlls / richedit / charlist.c
blobed4c0cc5f3340083d7fc78c5ae906b58be353d3f
1 /*
3 * Character List
5 * Copyright (c) 2000 by Jean-Claude Batista
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <stdarg.h>
23 #include <stdio.h>
24 #include <string.h>
25 #include <stddef.h>
26 #include <ctype.h>
27 #include <stdlib.h>
29 #include "charlist.h"
30 #include "windef.h"
31 #include "winbase.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
36 extern HANDLE RICHED32_hHeap;
38 void CHARLIST_Enqueue( CHARLIST* pCharList, char myChar )
40 CHARLISTENTRY* pNewEntry = HeapAlloc(RICHED32_hHeap, 0,sizeof(CHARLISTENTRY));
41 pNewEntry->pNext = NULL;
42 pNewEntry->myChar = myChar;
44 TRACE("\n");
46 if(pCharList->pTail == NULL)
48 pCharList->pHead = pCharList->pTail = pNewEntry;
50 else
52 CHARLISTENTRY* pCurrent = pCharList->pTail;
53 pCharList->pTail = pCurrent->pNext = pNewEntry;
56 pCharList->nCount++;
59 char CHARLIST_Dequeue(CHARLIST* pCharList)
61 CHARLISTENTRY* pCurrent;
62 char myChar;
64 TRACE("\n");
66 if(pCharList->nCount == 0)
67 return 0;
69 pCharList->nCount--;
70 myChar = pCharList->pHead->myChar;
71 pCurrent = pCharList->pHead->pNext;
72 HeapFree(RICHED32_hHeap, 0,pCharList->pHead);
74 if(pCharList->nCount == 0)
76 pCharList->pHead = pCharList->pTail = NULL;
78 else
80 pCharList->pHead = pCurrent;
83 return myChar;
86 int CHARLIST_GetNbItems(CHARLIST* pCharList)
88 TRACE("\n");
90 return pCharList->nCount;
93 void CHARLIST_FreeList(CHARLIST* pCharList){
94 TRACE("\n");
96 while(pCharList->nCount)
97 CHARLIST_Dequeue(pCharList);
100 /* this function counts the number of occurrences of a caracter */
101 int CHARLIST_CountChar(CHARLIST* pCharList, char myChar)
103 CHARLISTENTRY *pCurrent;
104 int nCount = 0;
106 TRACE("\n");
108 for(pCurrent =pCharList->pHead ;pCurrent;pCurrent=pCurrent->pNext)
109 if(pCurrent->myChar == myChar)
110 nCount++;
112 return nCount;
115 int CHARLIST_toBuffer(CHARLIST* pCharList, char* pBuffer, int nBufferSize)
118 TRACE("\n");
120 /* we add one to store a NULL caracter */
121 if(nBufferSize < pCharList->nCount + 1)
122 return pCharList->nCount;
124 for(;pCharList->nCount;pBuffer++)
125 *pBuffer = CHARLIST_Dequeue(pCharList);
127 *pBuffer = '\0';
129 return 0;