Updated patch,
removes now unnecessary casts.
Regards
Bert
---
source/interpret.c | 28 ++++++++++++++--------------
source/interpret.h | 7 ++++---
2 files changed, 18 insertions(+), 17 deletions(-)
diff --quilt old/source/interpret.c new/source/interpret.c
--- old/source/interpret.c
+++ new/source/interpret.c
@@ -163,14 +163,14 @@ static void stackdump(int n, int extra);
static Symbol *GlobalSymList = NULL;
/* List of all memory allocated for strings */
static char *AllocatedStrings = NULL;
-typedef struct {
+typedef struct SparseArrayEntryWrapperTag {
SparseArrayEntry data; /* LEAVE this as top entry */
int inUse; /* we use pointers to the data to refer to the
entire struct */
- struct SparseArrayEntryWrapper *next;
+ struct SparseArrayEntryWrapperTag *next;
} SparseArrayEntryWrapper;
static SparseArrayEntryWrapper *AllocatedSparseArrayEntries = NULL;
/* Message strings used in macros (so they don't get repeated every time
@@ -894,11 +894,11 @@ int AllocNStringCpy(NString *string, con
static SparseArrayEntry *allocateSparseArrayEntry(void)
{
SparseArrayEntryWrapper *mem;
mem = (SparseArrayEntryWrapper *)XtMalloc(sizeof(SparseArrayEntryWrapper));
- mem->next = (struct SparseArrayEntryWrapper *)AllocatedSparseArrayEntries;
+ mem->next = AllocatedSparseArrayEntries;
AllocatedSparseArrayEntries = mem;
#ifdef TRACK_GARBAGE_LEAKS
++numAllocatedSparseArrayElements;
#endif
return(&(mem->data));
@@ -924,11 +924,11 @@ static void MarkArrayContentsAsUsed(Spar
if (!(*(globalSEUse->value.val.str.rep - 1))) {
*(globalSEUse->value.val.str.rep - 1) = 1;
}
}
else if (globalSEUse->value.tag == ARRAY_TAG) {
- MarkArrayContentsAsUsed((SparseArrayEntry
*)globalSEUse->value.val.arrayPtr);
+ MarkArrayContentsAsUsed(globalSEUse->value.val.arrayPtr);
}
}
}
}
@@ -948,11 +948,11 @@ void GarbageCollectStrings(void)
for (p = AllocatedStrings; p != NULL; p = *((char **)p)) {
*(p + sizeof(char *)) = 0;
}
for (thisAP = AllocatedSparseArrayEntries;
- thisAP != NULL; thisAP = (SparseArrayEntryWrapper *)thisAP->next) {
+ thisAP != NULL; thisAP = thisAP->next) {
thisAP->inUse = 0;
}
/* Sweep the global symbol list, marking which strings are still
referenced */
@@ -962,11 +962,11 @@ void GarbageCollectStrings(void)
if (!(*(s->value.val.str.rep - 1))) {
*(s->value.val.str.rep - 1) = 1;
}
}
else if (s->value.tag == ARRAY_TAG) {
- MarkArrayContentsAsUsed((SparseArrayEntry *)s->value.val.arrayPtr);
+ MarkArrayContentsAsUsed(s->value.val.arrayPtr);
}
}
/* Collect all of the strings which remain unreferenced */
next = AllocatedStrings;
@@ -988,20 +988,20 @@ void GarbageCollectStrings(void)
nextAP = AllocatedSparseArrayEntries;
AllocatedSparseArrayEntries = NULL;
while (nextAP != NULL) {
thisAP = nextAP;
- nextAP = (SparseArrayEntryWrapper *)nextAP->next;
+ nextAP = nextAP->next;
if (thisAP->inUse != 0) {
- thisAP->next = (struct SparseArrayEntryWrapper
*)AllocatedSparseArrayEntries;
+ thisAP->next = AllocatedSparseArrayEntries;
AllocatedSparseArrayEntries = thisAP;
}
else {
#ifdef TRACK_GARBAGE_LEAKS
--numAllocatedSparseArrayElements;
#endif
- XtFree((void *)thisAP);
+ XtFree((char *)thisAP);
}
}
#ifdef TRACK_GARBAGE_LEAKS
printf("str count = %d\nary count = %d\n", numAllocatedStrings,
numAllocatedSparseArrayElements);
@@ -2283,13 +2283,13 @@ static void arrayDisposeNode(rbTreeNode
src->right = NULL;
src->parent = NULL;
src->color = -1;
}
-struct SparseArrayEntry *ArrayNew(void)
+SparseArrayEntry *ArrayNew(void)
{
- return((struct SparseArrayEntry *)rbTreeNew(arrayEmptyAllocator));
+ return((SparseArrayEntry *)rbTreeNew(arrayEmptyAllocator));
}
/*
** insert a DataValue into an array, allocate the array if needed
** keyStr must be a string that was allocated with AllocString()
@@ -2609,11 +2609,11 @@ static int beginArrayIter(void)
iteratorValPtr->tag = INT_TAG;
if (arrayVal.tag != ARRAY_TAG) {
return(execError("can't iterate non-array", NULL));
}
- iteratorValPtr->val.arrayPtr = (struct SparseArrayEntry
*)arrayIterateFirst(&arrayVal);
+ iteratorValPtr->val.arrayPtr = arrayIterateFirst(&arrayVal);
return(STAT_OK);
}
/*
** copy key to symbol if node is still valid, marked bad by a color of -1
@@ -2672,17 +2672,17 @@ static int arrayIter(void)
}
else {
return(execError("bad temporary iterator: %s", iterator->name));
}
- thisEntry = (SparseArrayEntry *)iteratorValPtr->val.arrayPtr;
+ thisEntry = iteratorValPtr->val.arrayPtr;
if (thisEntry && thisEntry->nodePtrs.color != -1) {
itemValPtr->tag = STRING_TAG;
itemValPtr->val.str.rep = thisEntry->key;
itemValPtr->val.str.len = strlen(thisEntry->key);
- iteratorValPtr->val.arrayPtr = (struct SparseArrayEntry
*)arrayIterateNext(thisEntry);
+ iteratorValPtr->val.arrayPtr = arrayIterateNext(thisEntry);
}
else {
PC = branchAddr;
}
return(STAT_OK);
diff --quilt old/source/interpret.h new/source/interpret.h
--- old/source/interpret.h
+++ new/source/interpret.h
@@ -55,10 +55,11 @@ enum typeTags {NO_TAG, INT_TAG, STRING_T
enum execReturnCodes {MACRO_TIME_LIMIT, MACRO_PREEMPT, MACRO_DONE,
MACRO_ERROR};
#define ARRAY_DIM_SEP "\034"
struct DataValueTag;
+struct SparseArrayEntryTag;
struct ProgramTag;
struct SymbolRec;
typedef union InstTag {
int (*func)(void);
@@ -82,15 +83,15 @@ typedef struct DataValueTag {
BuiltInSubr subr;
struct ProgramTag* prog;
XtActionProc xtproc;
Inst* inst;
struct DataValueTag* dataval;
- struct SparseArrayEntry *arrayPtr;
+ struct SparseArrayEntryTag *arrayPtr;
} val;
} DataValue;
-typedef struct {
+typedef struct SparseArrayEntryTag {
rbTreeNode nodePtrs; /* MUST BE FIRST ENTRY */
char *key;
DataValue value;
} SparseArrayEntry;
@@ -119,11 +120,11 @@ typedef struct {
void InitMacroGlobals(void);
SparseArrayEntry *arrayIterateFirst(DataValue *theArray);
SparseArrayEntry *arrayIterateNext(SparseArrayEntry *iterator);
-struct SparseArrayEntry *ArrayNew(void);
+SparseArrayEntry *ArrayNew(void);
Boolean ArrayInsert(DataValue* theArray, char* keyStr, DataValue* theValue);
void ArrayDelete(DataValue *theArray, char *keyStr);
void ArrayDeleteAll(DataValue *theArray);
unsigned ArraySize(DataValue *theArray);
Boolean ArrayGet(DataValue* theArray, char* keyStr, DataValue* theValue);
--
NEdit Develop mailing list - [email protected]
http://www.nedit.org/mailman/listinfo/develop