Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of RA8875 by
Diff: GraphicsDisplay.cpp
- Revision:
- 97:03c509c3db18
- Parent:
- 95:ef538bd687c0
diff -r 40b74dd3695b -r 03c509c3db18 GraphicsDisplay.cpp
--- a/GraphicsDisplay.cpp Sat Nov 28 15:39:44 2015 +0000
+++ b/GraphicsDisplay.cpp Mon Nov 30 11:58:32 2015 +0000
@@ -9,6 +9,12 @@
#include "Bitmap.h"
#include "string.h"
+#include "Utility.h" // private memory manager
+#ifndef UTILITY_H
+#define swMalloc malloc // use the standard
+#define swFree free
+#endif
+
//#define DEBUG "GD"
// ...
// INFO("Stuff to show %d", var); // new-line is automatically appended
@@ -400,7 +406,7 @@
// Read the color palette
colorCount = 1 << BMP_Info.biBitCount;
paletteSize = sizeof(RGBQUAD) * colorCount;
- colorPalette = (RGBQUAD *)malloc(paletteSize);
+ colorPalette = (RGBQUAD *)swMalloc(paletteSize);
if (colorPalette == NULL) {
fclose(Image);
return(not_enough_ram);
@@ -411,17 +417,17 @@
int lineBufSize = ((BPP_t * PixelWidth + 7)/8);
INFO("BPP_t %d, PixelWidth %d, lineBufSize %d", BPP_t, PixelWidth, lineBufSize);
- lineBuffer = (uint8_t *)malloc(lineBufSize);
+ lineBuffer = (uint8_t *)swMalloc(lineBufSize);
if (lineBuffer == NULL) {
- free(colorPalette);
+ swFree(colorPalette);
fclose(Image);
return(not_enough_ram);
}
- pixelBuffer = (color_t *)malloc(PixelWidth * sizeof(color_t));
+ pixelBuffer = (color_t *)swMalloc(PixelWidth * sizeof(color_t));
if (pixelBuffer == NULL) {
- free(lineBuffer);
+ swFree(lineBuffer);
if (colorPalette)
- free(colorPalette);
+ swFree(colorPalette);
fclose(Image);
return(not_enough_ram);
}
@@ -476,10 +482,10 @@
}
_EndGraphicsStream();
WindowMax();
- free(pixelBuffer); // don't leak memory
- free(lineBuffer);
+ swFree(pixelBuffer); // don't leak memory
+ swFree(lineBuffer);
if (colorPalette)
- free(colorPalette);
+ swFree(colorPalette);
return (noerror);
}
