Forked para SNOCC
Fork of RA8875 by
Diff: RA8875.cpp
- Revision:
- 97:03c509c3db18
- Parent:
- 96:40b74dd3695b
diff -r 40b74dd3695b -r 03c509c3db18 RA8875.cpp --- 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 {