diff --git a/expression.c b/expression.c index 56c445a..13a1451 100644 --- a/expression.c +++ b/expression.c @@ -461,6 +461,8 @@ void ExpressionPrefixOperator(struct ParseState *Parser, struct ExpressionStack /* pointer prefix arithmetic */ int Size = TypeSize(TopValue->Typ->FromType, 0, TRUE); struct Value *StackValue; + void *ResultPtr; + if (TopValue->Val->NativePointer == NULL) ProgramFail(Parser, "invalid use of a NULL pointer"); @@ -474,8 +476,9 @@ void ExpressionPrefixOperator(struct ParseState *Parser, struct ExpressionStack default: ProgramFail(Parser, "invalid operation"); break; } + ResultPtr = TopValue->Val->NativePointer; StackValue = ExpressionStackPushValueByType(Parser, StackTop, TopValue->Typ); - StackValue->Val->NativePointer = TopValue->Val->NativePointer; + StackValue->Val->NativePointer = ResultPtr; } else ProgramFail(Parser, "invalid operation"); diff --git a/heap.c b/heap.c index 5658908..026fc45 100644 --- a/heap.c +++ b/heap.c @@ -99,7 +99,7 @@ void HeapPushStackFrame() #endif *(void **)HeapStackTop = StackFrame; StackFrame = HeapStackTop; - HeapStackTop = (void *)((char *)HeapStackTop + MEM_ALIGN(sizeof(void *))); + HeapStackTop = (void *)((char *)HeapStackTop + MEM_ALIGN(sizeof(ALIGN_TYPE))); } /* pop the current stack frame, freeing all memory in the frame. can return NULL */ diff --git a/platform.h b/platform.h index 85e1de5..25aabe9 100644 --- a/platform.h +++ b/platform.h @@ -14,7 +14,8 @@ #define HEAP_SIZE 16384 /* default space for the heap and the stack */ #endif #define LARGE_INT_POWER_OF_TEN 1000000000 /* the largest power of ten which fits in an int on this architecture */ -#define ARCH_ALIGN_WORDSIZE sizeof(void *) /* memory alignment boundary on this architecture */ +#define ALIGN_TYPE void * /* the data type to use for alignment */ +#define ARCH_ALIGN_WORDSIZE sizeof(ALIGN_TYPE) /* memory alignment boundary on this architecture */ #define GLOBAL_TABLE_SIZE 97 /* global variable table */ #define STRING_TABLE_SIZE 97 /* shared string table size */