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
Revision 97:03c509c3db18, committed 2015-11-30
- Comitter:
- WiredHome
- Date:
- Mon Nov 30 11:58:32 2015 +0000
- Parent:
- 96:40b74dd3695b
- Commit message:
- Fixed comment - typo
Changed in this revision
| GraphicsDisplay.cpp | Show annotated file Show diff for this revision Revisions of this file |
| RA8875.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- 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);
}
--- a/RA8875.cpp Sat Nov 28 15:39:44 2015 +0000
+++ b/RA8875.cpp Mon Nov 30 11:58:32 2015 +0000
@@ -10,6 +10,12 @@
///
#include "RA8875.h"
+#include "Utility.h" // private memory manager
+#ifndef UTILITY_H
+#define swMalloc malloc // use the standard
+#define swFree free
+#endif
+
//#define DEBUG "RAIO"
// ...
// INFO("Stuff to show %d", var); // new-line is automatically appended
@@ -745,7 +751,7 @@
vScale >= 1 && vScale <= 4) {
uint8_t fncr1Val = ReadCommand(0x22);
- fncr1Val &= ~0x10; // do not disturbe the rotate flag
+ fncr1Val &= ~0x10; // do not disturb the rotate flag
if (alignment == align_full)
fncr1Val |= 0x80;
if (fillit == NOFILL)
@@ -1657,7 +1663,7 @@
// Allocate the memory we need to proceed
int lineBufSize = ((24 * w + 7)/8);
- lineBuffer = (uint8_t *)malloc(lineBufSize);
+ lineBuffer = (uint8_t *)swMalloc(lineBufSize);
if (lineBuffer == NULL) {
ERR("Not enough RAM for PrintScreen lineBuffer");
return(not_enough_ram);
@@ -1670,23 +1676,23 @@
// but is actually causing a failure later.
// This test helps determine if it is truly out of memory,
// or if malloc is broken.
- pixelBuffer = (color_t *)malloc(2 * w * sizeof(color_t));
+ pixelBuffer = (color_t *)swMalloc(2 * w * sizeof(color_t));
pixelBuffer2 = pixelBuffer + (w * sizeof(color_t));
#else
- pixelBuffer = (color_t *)malloc(w * sizeof(color_t));
- pixelBuffer2 = (color_t *)malloc(w * sizeof(color_t));
+ pixelBuffer = (color_t *)swMalloc(w * sizeof(color_t));
+ pixelBuffer2 = (color_t *)swMalloc(w * sizeof(color_t));
#endif
if (pixelBuffer == NULL || pixelBuffer2 == NULL) {
ERR("Not enough RAM for pixelBuffer");
#ifndef DOUBLEBUF
if (pixelBuffer2)
- free(pixelBuffer2);
+ swFree(pixelBuffer2);
#endif
if (pixelBuffer)
- free(pixelBuffer);
- free(lineBuffer);
+ swFree(pixelBuffer);
+ swFree(lineBuffer);
if (pixelBuffer)
- free(pixelBuffer);
+ swFree(pixelBuffer);
return(not_enough_ram);
}
@@ -1776,13 +1782,13 @@
#ifndef DOUBLEBUF
if (pixelBuffer2)
- free(pixelBuffer2);
+ swFree(pixelBuffer2);
#endif
if (pixelBuffer)
- free(pixelBuffer);
- free(lineBuffer);
+ swFree(pixelBuffer);
+ swFree(lineBuffer);
if (pixelBuffer)
- free(pixelBuffer);
+ swFree(pixelBuffer);
INFO("Image closed");
return noerror;
} else {
@@ -1824,7 +1830,7 @@
// Allocate the memory we need to proceed
int lineBufSize = ((24 * w + 7)/8);
- lineBuffer = (uint8_t *)malloc(lineBufSize);
+ lineBuffer = (uint8_t *)swMalloc(lineBufSize);
if (lineBuffer == NULL) {
ERR("Not enough RAM for PrintScreen lineBuffer");
return(not_enough_ram);
@@ -1837,23 +1843,23 @@
// but is actually causing a failure later.
// This test helps determine if it is truly out of memory,
// or if malloc is broken.
- pixelBuffer = (color_t *)malloc(2 * w * sizeof(color_t));
+ pixelBuffer = (color_t *)swMalloc(2 * w * sizeof(color_t));
pixelBuffer2 = pixelBuffer + (w * sizeof(color_t));
#else
- pixelBuffer = (color_t *)malloc(w * sizeof(color_t));
- pixelBuffer2 = (color_t *)malloc(w * sizeof(color_t));
+ pixelBuffer = (color_t *)swMalloc(w * sizeof(color_t));
+ pixelBuffer2 = (color_t *)swMalloc(w * sizeof(color_t));
#endif
if (pixelBuffer == NULL || pixelBuffer2 == NULL) {
ERR("Not enough RAM for pixelBuffer");
#ifndef DOUBLEBUF
if (pixelBuffer2)
- free(pixelBuffer2);
+ swFree(pixelBuffer2);
#endif
if (pixelBuffer)
- free(pixelBuffer);
- free(lineBuffer);
+ swFree(pixelBuffer);
+ swFree(lineBuffer);
if (pixelBuffer)
- free(pixelBuffer);
+ swFree(pixelBuffer);
return(not_enough_ram);
}
@@ -1862,13 +1868,13 @@
ERR("Can't open file for write");
#ifndef DOUBLEBUF
if (pixelBuffer2)
- free(pixelBuffer2);
+ swFree(pixelBuffer2);
#endif
if (pixelBuffer)
- free(pixelBuffer);
- free(lineBuffer);
+ swFree(pixelBuffer);
+ swFree(lineBuffer);
if (pixelBuffer)
- free(pixelBuffer);
+ swFree(pixelBuffer);
return(file_not_found);
}
@@ -1950,13 +1956,13 @@
fclose(Image);
#ifndef DOUBLEBUF
if (pixelBuffer2)
- free(pixelBuffer2);
+ swFree(pixelBuffer2);
#endif
if (pixelBuffer)
- free(pixelBuffer);
- free(lineBuffer);
+ swFree(pixelBuffer);
+ swFree(lineBuffer);
if (pixelBuffer)
- free(pixelBuffer);
+ swFree(pixelBuffer);
INFO("Image closed");
return noerror;
} else {
