|
From: Marcus B. <ma...@la...> - 2009-05-18 17:19:22
|
Hi... I'm trying to avoid spraying a whole bunch of NULL checks everywhere. I propose that a malloc failure in the CGreen code itself is fatal and we jump straight out of our own version of malloc()/realloc(). 1) In the master process, something is really wrong if malloc() fails. It means the test suite and CUT has been grabbing memory and locking it into RAM. We print the name of the test suite (so the user knows how far they got) and stop the test run. 2) In a test process, we just bomb the test. There is a problem keeping lint and valgrind happy in this case. In bombing out, we have to clean everything up. I propose that we use our own versions of malloc() and free() when inside tests. Either the exit handler or a longjmp() can be used to trigger the cleanup. I like the idea of registering unallocated blocks and cleaning them up en masse. It gets rid of free() calls in the code and is safer. What do you all think? yours, Marcus |