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.
I am using v1.06beta1_svn1151 version.
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 <= mem guaranteed?