Wednesday, February 4, 2009

Avoiding malloc like the plague

Tomorrow's release will have all calls to malloc and free replaced with Windows API calls. This has been a worthwhile exercise, as I've been aware for some time that MSDN documents that the behaviour of malloc is different between debug and release configurations. One of my personal bugbears is exactly that - differences in behaviour between debug and release configurations. I've been bitten before by having a debug configuration work perfectly only to see the release build go down in flames (and with no way to debug it). Never again.

For what it's worth, I'm using the Heap* calls, as they seem to do what I want how I want with the minimum of goofiness to get in the way.

2 comments:

Anonymous said...

The times the differences between mallocs actually makes a difference is the times when you have a bug that needs fixing, imho.

mhquake said...

I wouldn't disagree, that's what it's been in every case I've had it before; just makes it easier to fix if you have consistent behaviour.