nedmalloc: where does mem<fm come from?

Posted by Suma on Stack Overflow See other posts from Stack Overflow or by Suma
Published on 2010-03-25T16:00:49Z Indexed on 2010/03/25 16:03 UTC
Read the original article Hit count: 371

Filed under:
|
|
|

While implementing nedmalloc into my application, I am frequently hitting a situation when nedmalloc refuses to free a block of memory, claiming it did not allocate it.

While debugging I have come up to the point I see a particular condition which is failing, all other (including magic numbers) succeed. The condition is this:

if((size_t)mem-(size_t)fm>=(size_t)1<<(SIZE_T_BITSIZE-1)) return 0;

On Win32 this seems to be equivalent to:

if((int)((size_t)mem-(size_t)fm)<0) return 0;

Which seems to be the same as:

if((size_t)mem<(size_t)fm) return 0;

In my case I really see mem < fm. What I do not understand now is, where does this condition come from. I cannot find anything which would guarantee the fm <= m anywhere in code. Yet, "select isn't broken": I doubt it would really be a bug in nedmalloc, most likely I am doing something wrong somewhere, but I cannot find it. Once I turn debugging features of nedmalloc on, the problem goes away.

If someone here understands inner working of nedmalloc, could you please explain to me why is fm <= m?

© Stack Overflow or respective owner

Related posts about c

    Related posts about win32