several fixes in the CHECK part
This commit is contained in:
parent
b8d6eae391
commit
fc5c0ddc52
|
@ -65,7 +65,7 @@ acquire_malout() {
|
||||||
static char buf[BUFSIZ];
|
static char buf[BUFSIZ];
|
||||||
|
|
||||||
if (!malout) {
|
if (!malout) {
|
||||||
malout = fopen("mal.out", "w");
|
malout = freopen("mal.out", "w", stderr);
|
||||||
setbuf(malout, buf);
|
setbuf(malout, buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ check_mallinks(s) char *s; {
|
||||||
stat = BEZET;
|
stat = BEZET;
|
||||||
for_all_mallinks(ml) {
|
for_all_mallinks(ml) {
|
||||||
if (checksum_of(ml) != checksum(ml))
|
if (checksum_of(ml) != checksum(ml))
|
||||||
Error("mallink info at %ld corrupted", s, ml);
|
Error("mallink info at %lx corrupted", s, (long)ml);
|
||||||
if (working_on(ml)) {
|
if (working_on(ml)) {
|
||||||
stat = BEZET;
|
stat = BEZET;
|
||||||
continue;
|
continue;
|
||||||
|
@ -164,15 +164,15 @@ check_mallinks(s) char *s; {
|
||||||
if ( !last_mallink(ml) &&
|
if ( !last_mallink(ml) &&
|
||||||
phys_prev_of(phys_next_of(ml)) != ml
|
phys_prev_of(phys_next_of(ml)) != ml
|
||||||
)
|
)
|
||||||
Error("upward chain bad at %ld", s, ml);
|
Error("upward chain bad at %lx", s, (long)ml);
|
||||||
if ( !first_mallink(ml) &&
|
if ( !first_mallink(ml) &&
|
||||||
phys_next_of(phys_prev_of(ml)) != ml
|
phys_next_of(phys_prev_of(ml)) != ml
|
||||||
)
|
)
|
||||||
Error("downward chain bad at %ld", s, ml);
|
Error("downward chain bad at %lx", s, (long)ml);
|
||||||
if (free_of(ml)) {
|
if (free_of(ml)) {
|
||||||
if (stat == VRIJ)
|
if (stat == VRIJ)
|
||||||
Error("free mallink at %ld follows free mallink",
|
Error("free mallink at %lx follows free mallink",
|
||||||
s, ml);
|
s, (long)ml);
|
||||||
stat = VRIJ;
|
stat = VRIJ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -185,29 +185,29 @@ check_mallinks(s) char *s; {
|
||||||
if (working_on(ml))
|
if (working_on(ml))
|
||||||
continue;
|
continue;
|
||||||
if (!free_of(ml))
|
if (!free_of(ml))
|
||||||
Error("occupied mallink %ld occurs in free_list", s, ml);
|
Error("occupied mallink %lx occurs in free_list", s, (long)ml);
|
||||||
switch (mark_of(ml)) {
|
switch (mark_of(ml)) {
|
||||||
case IN_ML_LAST:
|
case IN_ML_LAST:
|
||||||
set_mark(ml, IN_FREE_LIST);
|
set_mark(ml, IN_FREE_LIST);
|
||||||
break;
|
break;
|
||||||
case IN_FREE_LIST:
|
case IN_FREE_LIST:
|
||||||
Error("mallink %ld occurs in 2 free_lists",
|
Error("mallink %lx occurs in 2 free_lists",
|
||||||
s, ml);
|
s, (long)ml);
|
||||||
default:
|
default:
|
||||||
Error("unknown mallink %ld in free_list",
|
Error("unknown mallink %lx in free_list",
|
||||||
s, ml);
|
s, (long)ml);
|
||||||
}
|
}
|
||||||
if (size_of(ml) < size)
|
if (size_of(ml) < size)
|
||||||
Error("size of mallink %ld too small", s, ml);
|
Error("size of mallink %lx too small", s, (long)ml);
|
||||||
if (size_of(ml) >= 2*size)
|
if (size_of(ml) >= 2*size)
|
||||||
Error("size of mallink %ld too large", s, ml);
|
Error("size of mallink %lx too large", s, (long)ml);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for_all_mallinks (ml) {
|
for_all_mallinks (ml) {
|
||||||
if (working_on(ml))
|
if (working_on(ml))
|
||||||
continue;
|
continue;
|
||||||
if (free_of(ml) && mark_of(ml) != IN_FREE_LIST)
|
if (free_of(ml) && mark_of(ml) != IN_FREE_LIST)
|
||||||
Error("free mallink %ld is in no free_list", s, ml);
|
Error("free mallink %lx is in no free_list", s, (long)ml);
|
||||||
set_mark(ml, CLEAR);
|
set_mark(ml, CLEAR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,6 +172,7 @@ free(addr)
|
||||||
set_log_next(ml, *stp);
|
set_log_next(ml, *stp);
|
||||||
*stp = ml;
|
*stp = ml;
|
||||||
set_store(ml, 1);
|
set_store(ml, 1);
|
||||||
|
calc_checksum(ml);
|
||||||
check_mallinks("free fast exit");
|
check_mallinks("free fast exit");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -262,6 +263,7 @@ realloc(addr, n)
|
||||||
if (! stp1) store[(size_of(ml) >> LOG_MIN_SIZE) - 1] = stp;
|
if (! stp1) store[(size_of(ml) >> LOG_MIN_SIZE) - 1] = stp;
|
||||||
else set_log_next(stp1, stp);
|
else set_log_next(stp1, stp);
|
||||||
set_store(ml, 0);
|
set_store(ml, 0);
|
||||||
|
calc_checksum(ml);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (free_of(ml)) {
|
if (free_of(ml)) {
|
||||||
|
|
|
@ -18,19 +18,19 @@ publicdata mallink *ml_last;
|
||||||
|
|
||||||
#define __bits(ml) ((size_type)_phys_prev_of(ml) & BITS)
|
#define __bits(ml) ((size_type)_phys_prev_of(ml) & BITS)
|
||||||
#define __free_of(ml) ((size_type)_phys_prev_of(ml) & FREE_BIT)
|
#define __free_of(ml) ((size_type)_phys_prev_of(ml) & FREE_BIT)
|
||||||
#define __phys_prev_of(ml) (mallink *)((size_type)_phys_prev_of(ml) & ~FREE_BIT)
|
#define __phys_prev_of(ml) (mallink *)((size_type)_phys_prev_of(ml) & ~BITS)
|
||||||
#define prev_size_of(ml) ((char *)(ml) - \
|
#define prev_size_of(ml) ((char *)(ml) - \
|
||||||
(char *)__phys_prev_of(ml) - \
|
(char *)__phys_prev_of(ml) - \
|
||||||
mallink_size() \
|
mallink_size() \
|
||||||
)
|
)
|
||||||
#define set_phys_prev(ml,e) \
|
#define set_phys_prev(ml,e) \
|
||||||
(_phys_prev_of(ml) = (mallink *) ((char *)e + __free_of(ml)))
|
(_phys_prev_of(ml) = (mallink *) ((char *)e + __bits(ml)))
|
||||||
|
|
||||||
#ifdef CHECK
|
#ifdef CHECK
|
||||||
public Error();
|
public Error();
|
||||||
#define phys_prev_of(ml) (mallink *) \
|
#define phys_prev_of(ml) (mallink *) \
|
||||||
(first_mallink(ml) ? \
|
(first_mallink(ml) ? \
|
||||||
(char *)Error("phys_prev_of first_mallink %ld", "somewhere", ml) : \
|
(char *)Error("phys_prev_of first_mallink %lx", "somewhere", (long)ml) : \
|
||||||
(char *)__phys_prev_of(ml) \
|
(char *)__phys_prev_of(ml) \
|
||||||
)
|
)
|
||||||
#else ndef CHECK
|
#else ndef CHECK
|
||||||
|
|
Loading…
Reference in a new issue