Sunday, November 25, 2007

Well, I'm working with a elliptic curve library using a personal MP library.
The library has some problems and I'm porting to 64 bit, one thing I have is that
Sometimes i get Double-free errors when freeing malloced stuff.
I did a little function that wraps free() called 'sfree()'
It writes in the memory address that allocates the pointee (memory address to the data)
And makes the pointee NULL, so you can verify if the function has been freed without using
a structure that handles the status of a pointer.
The way i did is sending the memory address of the pointer instead of the pointer
using a macro to permit the user not to type the & and writing the NULL value using a void **
This idea came with a conversation with Rommel in a starbucks
but well the code is here
Maybe this can be useful for you.

Eduardo Ruiz Duarte (beck)