2
*******************************************************************************
4
* Copyright (C) 1998-2000, International Business Machines
5
* Corporation and others. All Rights Reserved.
7
*******************************************************************************
11
* Modification History:
13
* Date Name Description
14
* 06/01/99 stephen Creation.
15
*******************************************************************************
20
#include "unicode/ustring.h"
26
make_rbitem(const UChar *tag,
27
const struct SList *data,
33
if(U_FAILURE(*status)) return 0;
35
item = (struct SRBItem*) uprv_malloc(sizeof(struct SRBItem));
37
*status = U_MEMORY_ALLOCATION_ERROR;
41
/* s = (UChar*) uprv_malloc(sizeof(UChar) * (u_strlen(tag) + 1)); */
42
s = (char*) uprv_malloc(sizeof(char) * (u_strlen(tag) + 1));
44
*status = U_MEMORY_ALLOCATION_ERROR;
47
u_UCharsToChars(tag, s, u_strlen(tag)+1);
48
/* u_strcpy(s, tag); */
51
item->fData = (struct SList*) data;
58
rblist_open(UErrorCode *status)
60
struct SRBItemList *list;
62
if(U_FAILURE(*status)) return 0;
64
list = (struct SRBItemList*) uprv_malloc(sizeof(struct SRBItemList));
66
*status = U_MEMORY_ALLOCATION_ERROR;
73
/* list->fData = 0; */
76
list->fKeys = (char *) uprv_malloc(sizeof(char) * 65532);
82
void rblist_close(struct SRBItemList *list,
86
struct SRBItem *current;
87
struct SRBItem *prev = NULL;
89
if(U_FAILURE(*status)) return;
90
current = list->fFirst;
91
/* deallocate each list */
92
/* for(i = 0; i < list->fCount; ++i) { */
93
while(current != NULL) {
95
/* switch(list->fData[i]->fData->fType) { */
96
switch(current->fData->fType) {
98
strlist_close(current->fData, status);
102
strlist2d_close(current->fData, status);
106
taglist_close(current->fData, status);
113
current=current->fNext;
116
/* uprv_free(list->fData); */
117
uprv_free(list->fLocale);
118
uprv_free(list->fKeys);
123
void rblist_setlocale(struct SRBItemList *list,
127
if(U_FAILURE(*status)) return;
129
/* Allocate enough space */
130
list->fLocale = (UChar*) uprv_realloc(list->fLocale,
131
sizeof(UChar) * (u_strlen(locale) + 1));
132
if(list->fLocale == 0) {
133
*status = U_MEMORY_ALLOCATION_ERROR;
137
u_strcpy(list->fLocale, locale);
140
void rblist_add(struct SRBItemList *list,
146
struct SRBItem *current;
147
struct SRBItem *prev = NULL;
149
if(U_FAILURE(*status)) return;
150
/* here we need to traverse the list */
154
s->fStrKey = list->fKeyPoint;
156
uprv_strcpy((list->fKeys)+list->fKeyPoint, s->fTag);
158
list->fKeyPoint += uprv_strlen(s->fTag)+1;
162
/* is list still empty? */
163
if(list->fFirst == NULL) {
168
current = list->fFirst;
171
while(current != NULL) {
172
if(uprv_strcmp(current->fTag, s->fTag)<0) {
174
current = current->fNext;
175
} else { /*we're either in front of list, or in middle*/
176
if(prev == NULL) { /*front of the list*/
178
} else { /*middle of the list*/