So now that my memory leak is fixed I am still having issues with my simple 12x position message queue.
I am just trying to move the pointers around in order to update the list but more than the last pointer is being updated and I cannot see why. Any help would be appreciated.
#define SCREEN_BUFFER_SZ 12
char *tftBuffer[SCREEN_BUFFER_SZ]={0};
initBuffer(tftBuffer);
pushBuffer(tftBuffer,strcpy_P(buffer, PSTR("Boomer online @ 10.0.0.177")));
void initBuffer (char** data) {
for (int i=0; i < SCREEN_BUFFER_SZ; i++) {
data[i]=" ";
}
}
void printBuffer (char** printData) {
int x, y;
for (int i; i < SCREEN_BUFFER_SZ; i++) {
y = 70 + (10*i);
myGLCD.setFont(SmallFont);
myGLCD.setBackColor(VGA_BLACK);
myGLCD.setColor(VGA_WHITE);
myGLCD.print((char*) printData[i], 20, y);
}
}
void pushBuffer (char** bufferData, char* str) {
char* localBuffer;
char* localBuffer2;
int x,y;
// clear out previous characters
for (int i; i < SCREEN_BUFFER_SZ; i++) {
y = 70 + (10*i);
myGLCD.setFont(SmallFont);
myGLCD.setBackColor(VGA_BLACK);
myGLCD.setColor(VGA_BLACK);
myGLCD.print((char*) bufferData[i], 20, y);
}
for (int i=SCREEN_BUFFER_SZ-1; i>=0; i--) {
if (i==11) {
// insert string @ n=11
localBuffer2=str;
}
// save existing data @ n
localBuffer=bufferData[i];
// insert n-1 data @ n
bufferData[i]=localBuffer2;
// update n-1 data
localBuffer2=localBuffer;
}
printBuffer(bufferData);
}