#include #include /*At the start of the execution : the whole array is empty*/ symbolTable = malloc(sizeof(symbol) * START_TABLE_SIZE) currentIndex = 0; maxIndex = START_TABLE_SIZE; /*Checks for the length of the array and reallocates if necessary*/ void checkArraySanity(){ if (currentIndex == maxIndex){ reallocateArray(maxIndex * 2); } else { if (currentIndex < maxIndex / 2){ reallocateArray(maxIndex / 2); } } } void reallocateArray(int size){ Symbol* newSymbolTable = malloc(sizeof (symbol) * size); // we double the size of the array Symbol* oldSymbolTable = symbolTable; // we double the size of the array free(oldSymbolTable); for(int i = 0; i < currentIndex; i++){ newSymbolTable[i] = oldSymbolTable[i]; } symbolTable = newSymbolTable; }