adelete is supposed to be quiet on valid pointers
This commit is contained in:
parent
3c07bc66f0
commit
28a0e28b1d
11
aalloc.c
11
aalloc.c
@ -1,6 +1,6 @@
|
|||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/aalloc.c,v 1.17 2008/11/12 06:35:27 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/aalloc.c,v 1.18 2008/11/12 06:38:08 tg Exp $");
|
||||||
|
|
||||||
/* mksh integration of aalloc */
|
/* mksh integration of aalloc */
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ static long pagesz;
|
|||||||
size += extra; \
|
size += extra; \
|
||||||
} while (/* CONSTCOND */ 0)
|
} while (/* CONSTCOND */ 0)
|
||||||
|
|
||||||
static void adelete_leak(PArea, PBlock, const char *);
|
static void adelete_leak(PArea, PBlock, bool, const char *);
|
||||||
static PBlock check_bp(PArea, const char *, TCookie);
|
static PBlock check_bp(PArea, const char *, TCookie);
|
||||||
static TPtr *check_ptr(void *, PArea, PBlock *, const char *, const char *);
|
static TPtr *check_ptr(void *, PArea, PBlock *, const char *, const char *);
|
||||||
|
|
||||||
@ -279,7 +279,7 @@ track_check(void)
|
|||||||
AALLOC_WARN("leaking empty area %p (%p %lu)", ap,
|
AALLOC_WARN("leaking empty area %p (%p %lu)", ap,
|
||||||
bp, (unsigned long)(bp->endp - (char *)bp));
|
bp, (unsigned long)(bp->endp - (char *)bp));
|
||||||
} else
|
} else
|
||||||
adelete_leak(ap, bp, "at exit");
|
adelete_leak(ap, bp, true, "at exit");
|
||||||
free(bp);
|
free(bp);
|
||||||
track_next:
|
track_next:
|
||||||
track = (PArea)ap->prev.pv;
|
track = (PArea)ap->prev.pv;
|
||||||
@ -289,7 +289,7 @@ track_check(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
adelete_leak(PArea ap, PBlock bp, const char *when)
|
adelete_leak(PArea ap, PBlock bp, bool always_warn, const char *when)
|
||||||
{
|
{
|
||||||
TPtr *cp;
|
TPtr *cp;
|
||||||
|
|
||||||
@ -297,6 +297,7 @@ adelete_leak(PArea ap, PBlock bp, const char *when)
|
|||||||
bp->last -= PVALIGN;
|
bp->last -= PVALIGN;
|
||||||
cp = *((void **)bp->last);
|
cp = *((void **)bp->last);
|
||||||
cp->iv ^= bp->cookie;
|
cp->iv ^= bp->cookie;
|
||||||
|
if (always_warn || cp->pv != bp->last)
|
||||||
AALLOC_WARN("leaking %s pointer %p in area %p (%p %lu) %s",
|
AALLOC_WARN("leaking %s pointer %p in area %p (%p %lu) %s",
|
||||||
cp->pv == bp->last ? "valid" : "underflown",
|
cp->pv == bp->last ? "valid" : "underflown",
|
||||||
(char *)cp + PVALIGN, ap, bp,
|
(char *)cp + PVALIGN, ap, bp,
|
||||||
@ -316,7 +317,7 @@ adelete(PArea *pap)
|
|||||||
/* ignore invalid areas */
|
/* ignore invalid areas */
|
||||||
if ((bp = check_bp(*pap, "adelete", 0)) != NULL) {
|
if ((bp = check_bp(*pap, "adelete", 0)) != NULL) {
|
||||||
if (bp->last != (char *)&bp->storage)
|
if (bp->last != (char *)&bp->storage)
|
||||||
adelete_leak(*pap, bp, "in adelete");
|
adelete_leak(*pap, bp, false, "in adelete");
|
||||||
free(bp);
|
free(bp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user