dynamic memory allocation problem...

23 Feb 2011

Hi, I have an instance of HTTPServer running in embed. Basically, it just listens on POST request from clients. Just like a regular dynamic webserver, im running some form of a single table database and process information from it ready to be sent to clients. My table is built from a text file parsed from the LocalFilesystem. Due to the dynamic nature of this table, I'm using a char* to represent it in memory. And because the table in memory changes, I have to update the textfile in the LocalFileSystem by writing to it (append, write, etc).

The problem is, I can do an http request (many many times) that only involves reading the textfile to memory and the mbed works fine. But when I do a an operation/request that involves updating the table in the filesystem, the mbed will almost certainly crash on the next read on the filesystem (i.e., i don't get a response in my browser...).Memory are allocated on demand (using malloc()) and destroyed whenever it's no longer needed (using free()). I am also very careful in allocating just enough blocks to hold any information (i don't use something like malloc(sizeof(char) * 3000)) just because I can.

Unfortunately, mbed seems to crash whenever I do a write on the filesystem (on the next read). I don't know what's going on so Im pretty clueless on how to make the mbed/application stable enough not to crash.

23 Feb 2011

table is represented by a char(*)(*)(*) pointer in memory