I've been working on a library to read bitmap files stored on external flash using the SerialFLash library and I've hit a roadblock that I'm pretty sure is related to the way I'm trying to implement the malloc and realloc functions, but I'm also wondering if there is anything teensy specific that I may not be taking into account.
Initial load of bitmap file and initial malloc() of array works just fine. It's when I try to free() the memory and realloc() that everything freezes. My implementation is shown in the code below.
.h
.cpp
Initial load of bitmap file and initial malloc() of array works just fine. It's when I try to free() the memory and realloc() that everything freezes. My implementation is shown in the code below.
.h
Code:
//Pointer for location to hold pixel data
char * image=0;
CRGB *palette;
.cpp
Code:
void sfBMP::load(const char *filename){
free(palette);
free(image);
file.close();
file = SerialFlash.open(filename);
address = file.getFlashAddress();
fileSize = file.size();
image = (char*) realloc(image,fileSize);
SerialFlash.read(address,image,fileSize);
tracker = 0;
verify();
};