Library to control a Graphics TFT connected to 4-wire SPI - revised for the Raio RA8875 Display Controller.

Dependents:   FRDM_RA8875_mPaint RA8875_Demo RA8875_KeyPadDemo SignalGenerator ... more

Fork of SPI_TFT by Peter Drescher

See Components - RA8875 Based Display

Enhanced touch-screen support - where it previous supported both the Resistive Touch and Capacitive Touch based on the FT5206 Touch Controller, now it also has support for the GSL1680 Touch Controller.

Offline Help Manual (Windows chm)

/media/uploads/WiredHome/ra8875.zip.bin (download, rename to .zip and unzip)

Files at this revision

API Documentation at this revision

Comitter:
WiredHome
Date:
Sun Aug 31 15:54:42 2014 +0000
Parent:
62:ba5d33438fda
Child:
70:4cb28f9472fc
Commit message:
Eliminate possibility of memory leak.

Changed in this revision

GraphicsDisplay.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/GraphicsDisplay.cpp	Sun Aug 17 15:38:51 2014 +0000
+++ b/GraphicsDisplay.cpp	Sun Aug 31 15:54:42 2014 +0000
@@ -439,7 +439,9 @@
             //HexDump("Line", lineBuffer, lineBufSize);
             fwrite(lineBuffer, sizeof(char), lb, Image);
         }
-        fclose(Image);       
+        fclose(Image);
+        free(pixelBuffer);  // don't leak memory.
+        free(lineBuffer);
         INFO("Image closed"); 
         return noerror;
     } else {
@@ -453,6 +455,7 @@
     RGBQUAD * colorPalette = NULL;
     int colorCount;
     uint8_t * lineBuffer = NULL;
+    color_t * pixelBuffer = NULL;
     uint16_t BPP_t;
     uint32_t PixelWidth, PixelHeight;
     unsigned int    i, offset;
@@ -500,10 +503,11 @@
         fclose(Image);
         return(not_enough_ram);
     }
-    color_t * pixelBuffer = (color_t *)malloc(PixelWidth * sizeof(color_t));
+    pixelBuffer = (color_t *)malloc(PixelWidth * sizeof(color_t));
     if (pixelBuffer == NULL) {
-        free(colorPalette);
         free(lineBuffer);
+        if (colorPalette)
+            free(colorPalette);
         fclose(Image);
         return(not_enough_ram);
     }
@@ -562,8 +566,10 @@
     }
     _EndGraphicsStream();
     WindowMax();
+    free(pixelBuffer);      // don't leak memory
     free(lineBuffer);
-    free(colorPalette);
+    if (colorPalette)
+        free(colorPalette);
     return (noerror);
 }