CVS rebase
[nedit-bw.git] / there-is-no-struct-SparseArrayEntry.patch
blob28378d42d6c2c3dfaa2b142babac0a9e77a1d5ef
1 ---
3 source/interpret.c | 28 ++++++++++++++--------------
4 source/interpret.h | 7 ++++---
5 2 files changed, 18 insertions(+), 17 deletions(-)
7 diff --quilt old/source/interpret.c new/source/interpret.c
8 --- old/source/interpret.c
9 +++ new/source/interpret.c
10 @@ -163,14 +163,14 @@ static void stackdump(int n, int extra);
11 static Symbol *GlobalSymList = NULL;
13 /* List of all memory allocated for strings */
14 static char *AllocatedStrings = NULL;
16 -typedef struct {
17 +typedef struct SparseArrayEntryWrapperTag {
18 SparseArrayEntry data; /* LEAVE this as top entry */
19 int inUse; /* we use pointers to the data to refer to the entire struct */
20 - struct SparseArrayEntryWrapper *next;
21 + struct SparseArrayEntryWrapperTag *next;
22 } SparseArrayEntryWrapper;
24 static SparseArrayEntryWrapper *AllocatedSparseArrayEntries = NULL;
26 /* Message strings used in macros (so they don't get repeated every time
27 @@ -894,11 +894,11 @@ int AllocNStringCpy(NString *string, con
28 static SparseArrayEntry *allocateSparseArrayEntry(void)
30 SparseArrayEntryWrapper *mem;
32 mem = (SparseArrayEntryWrapper *)XtMalloc(sizeof(SparseArrayEntryWrapper));
33 - mem->next = (struct SparseArrayEntryWrapper *)AllocatedSparseArrayEntries;
34 + mem->next = AllocatedSparseArrayEntries;
35 AllocatedSparseArrayEntries = mem;
36 #ifdef TRACK_GARBAGE_LEAKS
37 ++numAllocatedSparseArrayElements;
38 #endif
39 return(&(mem->data));
40 @@ -924,11 +924,11 @@ static void MarkArrayContentsAsUsed(Spar
41 if (!(*(globalSEUse->value.val.str.rep - 1))) {
42 *(globalSEUse->value.val.str.rep - 1) = 1;
45 else if (globalSEUse->value.tag == ARRAY_TAG) {
46 - MarkArrayContentsAsUsed((SparseArrayEntry *)globalSEUse->value.val.arrayPtr);
47 + MarkArrayContentsAsUsed(globalSEUse->value.val.arrayPtr);
53 @@ -948,11 +948,11 @@ void GarbageCollectStrings(void)
54 for (p = AllocatedStrings; p != NULL; p = *((char **)p)) {
55 *(p + sizeof(char *)) = 0;
58 for (thisAP = AllocatedSparseArrayEntries;
59 - thisAP != NULL; thisAP = (SparseArrayEntryWrapper *)thisAP->next) {
60 + thisAP != NULL; thisAP = thisAP->next) {
61 thisAP->inUse = 0;
64 /* Sweep the global symbol list, marking which strings are still
65 referenced */
66 @@ -962,11 +962,11 @@ void GarbageCollectStrings(void)
67 if (!(*(s->value.val.str.rep - 1))) {
68 *(s->value.val.str.rep - 1) = 1;
71 else if (s->value.tag == ARRAY_TAG) {
72 - MarkArrayContentsAsUsed((SparseArrayEntry *)s->value.val.arrayPtr);
73 + MarkArrayContentsAsUsed(s->value.val.arrayPtr);
77 /* Collect all of the strings which remain unreferenced */
78 next = AllocatedStrings;
79 @@ -988,20 +988,20 @@ void GarbageCollectStrings(void)
81 nextAP = AllocatedSparseArrayEntries;
82 AllocatedSparseArrayEntries = NULL;
83 while (nextAP != NULL) {
84 thisAP = nextAP;
85 - nextAP = (SparseArrayEntryWrapper *)nextAP->next;
86 + nextAP = nextAP->next;
87 if (thisAP->inUse != 0) {
88 - thisAP->next = (struct SparseArrayEntryWrapper *)AllocatedSparseArrayEntries;
89 + thisAP->next = AllocatedSparseArrayEntries;
90 AllocatedSparseArrayEntries = thisAP;
92 else {
93 #ifdef TRACK_GARBAGE_LEAKS
94 --numAllocatedSparseArrayElements;
95 #endif
96 - XtFree((void *)thisAP);
97 + XtFree((char *)thisAP);
101 #ifdef TRACK_GARBAGE_LEAKS
102 printf("str count = %d\nary count = %d\n", numAllocatedStrings, numAllocatedSparseArrayElements);
103 @@ -2278,13 +2278,13 @@ static void arrayDisposeNode(rbTreeNode
104 src->right = NULL;
105 src->parent = NULL;
106 src->color = -1;
109 -struct SparseArrayEntry *ArrayNew(void)
110 +SparseArrayEntry *ArrayNew(void)
112 - return((struct SparseArrayEntry *)rbTreeNew(arrayEmptyAllocator));
113 + return((SparseArrayEntry *)rbTreeNew(arrayEmptyAllocator));
117 ** insert a DataValue into an array, allocate the array if needed
118 ** keyStr must be a string that was allocated with AllocString()
119 @@ -2604,11 +2604,11 @@ static int beginArrayIter(void)
120 iteratorValPtr->tag = INT_TAG;
121 if (arrayVal.tag != ARRAY_TAG) {
122 return(execError("can't iterate non-array", NULL));
125 - iteratorValPtr->val.arrayPtr = (struct SparseArrayEntry *)arrayIterateFirst(&arrayVal);
126 + iteratorValPtr->val.arrayPtr = arrayIterateFirst(&arrayVal);
127 return(STAT_OK);
131 ** copy key to symbol if node is still valid, marked bad by a color of -1
132 @@ -2667,17 +2667,17 @@ static int arrayIter(void)
134 else {
135 return(execError("bad temporary iterator: %s", iterator->name));
138 - thisEntry = (SparseArrayEntry *)iteratorValPtr->val.arrayPtr;
139 + thisEntry = iteratorValPtr->val.arrayPtr;
140 if (thisEntry && thisEntry->nodePtrs.color != -1) {
141 itemValPtr->tag = STRING_TAG;
142 itemValPtr->val.str.rep = thisEntry->key;
143 itemValPtr->val.str.len = strlen(thisEntry->key);
145 - iteratorValPtr->val.arrayPtr = (struct SparseArrayEntry *)arrayIterateNext(thisEntry);
146 + iteratorValPtr->val.arrayPtr = arrayIterateNext(thisEntry);
148 else {
149 PC = branchAddr;
151 return(STAT_OK);
152 diff --quilt old/source/interpret.h new/source/interpret.h
153 --- old/source/interpret.h
154 +++ new/source/interpret.h
155 @@ -55,10 +55,11 @@ enum typeTags {NO_TAG, INT_TAG, STRING_T
156 enum execReturnCodes {MACRO_TIME_LIMIT, MACRO_PREEMPT, MACRO_DONE, MACRO_ERROR};
158 #define ARRAY_DIM_SEP "\034"
160 struct DataValueTag;
161 +struct SparseArrayEntryTag;
162 struct ProgramTag;
163 struct SymbolRec;
165 typedef union InstTag {
166 int (*func)(void);
167 @@ -82,15 +83,15 @@ typedef struct DataValueTag {
168 BuiltInSubr subr;
169 struct ProgramTag* prog;
170 XtActionProc xtproc;
171 Inst* inst;
172 struct DataValueTag* dataval;
173 - struct SparseArrayEntry *arrayPtr;
174 + struct SparseArrayEntryTag *arrayPtr;
175 } val;
176 } DataValue;
178 -typedef struct {
179 +typedef struct SparseArrayEntryTag {
180 rbTreeNode nodePtrs; /* MUST BE FIRST ENTRY */
181 char *key;
182 DataValue value;
183 } SparseArrayEntry;
185 @@ -119,11 +120,11 @@ typedef struct {
187 void InitMacroGlobals(void);
189 SparseArrayEntry *arrayIterateFirst(DataValue *theArray);
190 SparseArrayEntry *arrayIterateNext(SparseArrayEntry *iterator);
191 -struct SparseArrayEntry *ArrayNew(void);
192 +SparseArrayEntry *ArrayNew(void);
193 Boolean ArrayInsert(DataValue* theArray, char* keyStr, DataValue* theValue);
194 void ArrayDelete(DataValue *theArray, char *keyStr);
195 void ArrayDeleteAll(DataValue *theArray);
196 unsigned ArraySize(DataValue *theArray);
197 Boolean ArrayGet(DataValue* theArray, char* keyStr, DataValue* theValue);