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)

2 comments:

rommel.sv said...

As already we talk, thee "improvement" It minimize your memory problems leading you to a better perfomance over the "library". It
could be a nice idea if you can "write this down" in order to make a graph to show results. And placeit over the wiki [http:://wiki.lidsol.net] in a new area called: "Better programming Practices"

Thx for the code :) Keep Blogging Code!

beck said...

Well, in fact I'll debug in Linux using valgring function per function.

I think that's gonna clean the code.

And check the unlikely() and likely() stuff that need to be changed in critical functions like arithmetic ones.

I have the old version. I ll prove it , but well i think is gonna be like 24 times faster.

And maybe I can do a graph as you say for memory usage , cpu time , and user time

Thanks for the comment.