Extra assertions on free if SLOWDEBUG is enabled: check whether the block exists and has not been freed before
This commit is contained in:
parent
4b34ff6903
commit
1137ba9b32
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
/* replace undef by define */
|
/* replace undef by define */
|
||||||
#define DEBUG /* check assertions */
|
#define DEBUG /* check assertions */
|
||||||
#undef SLOWDEBUG /* some extra test loops (requires DEBUG) */
|
#define SLOWDEBUG /* some extra test loops (requires DEBUG) */
|
||||||
|
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
|
@ -179,6 +179,34 @@ free(void *ptr)
|
||||||
if (p == 0)
|
if (p == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#ifdef SLOWDEBUG
|
||||||
|
{
|
||||||
|
int found;
|
||||||
|
char *curr;
|
||||||
|
|
||||||
|
/* block must be in block list */
|
||||||
|
assert(_bottom);
|
||||||
|
found = 0;
|
||||||
|
for (curr = _bottom; (next = NextSlot(curr)) != 0; curr = next) {
|
||||||
|
assert(next > curr);
|
||||||
|
if (curr == p) found = 1;
|
||||||
|
}
|
||||||
|
if (curr == p) found = 1;
|
||||||
|
assert(found);
|
||||||
|
|
||||||
|
/* block must not be in free list */
|
||||||
|
if (_empty) {
|
||||||
|
found = 0;
|
||||||
|
for (curr = _empty; (next = NextFree(curr)) != 0; curr = next) {
|
||||||
|
assert(next > curr);
|
||||||
|
if (curr == p) found = 1;
|
||||||
|
}
|
||||||
|
if (curr == p) found = 1;
|
||||||
|
assert(!found);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
assert((char *) NextSlot(p) > p);
|
assert((char *) NextSlot(p) > p);
|
||||||
for (prev = 0, next = _empty; next != 0; prev = next, next = NextFree(next))
|
for (prev = 0, next = _empty; next != 0; prev = next, next = NextFree(next))
|
||||||
if (p < next)
|
if (p < next)
|
||||||
|
|
Loading…
Reference in a new issue