fixed types because of the 2-4 version
This commit is contained in:
parent
dc500c3463
commit
bc137646df
5 changed files with 29 additions and 21 deletions
|
@ -12,7 +12,7 @@ private acquire_malout(void), check_ml_last(const char *s);
|
|||
private dump_all_mallinks(void), dump_free_list(int i);
|
||||
private dump_mallink(const char *s, mallink *ml), print_loop(mallink *ml);
|
||||
private working_on(mallink *ml);
|
||||
private unsigned int checksum(mallink *ml);
|
||||
private size_type checksum(mallink *ml);
|
||||
static FILE *malout;
|
||||
|
||||
private mallink *free_list_entry(int i);
|
||||
|
@ -121,7 +121,7 @@ dump_mallink(const char *s, mallink *ml) {
|
|||
}
|
||||
fprintf(malout, " p_s: %p;", prev_size_of(ml));
|
||||
fprintf(malout, " t_s: %p;", _this_size_of(ml));
|
||||
fprintf(malout, " sz: %p;", size_of(ml));
|
||||
fprintf(malout, " sz: %lu;", (unsigned long) size_of(ml));
|
||||
fprintf(malout, " fr: %d;", free_of(ml));
|
||||
fprintf(malout, "\n");
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ dump_mallink(const char *s, mallink *ml) {
|
|||
private
|
||||
check_mallinks(const char *s) {
|
||||
mallink *ml;
|
||||
unsigned int size;
|
||||
size_type size;
|
||||
int i;
|
||||
char stat;
|
||||
|
||||
|
@ -215,16 +215,16 @@ check_ml_last(const char *s) {
|
|||
Error("size of ml_last == 0, at %p", s, ml_last);
|
||||
}
|
||||
|
||||
private unsigned int
|
||||
private size_type
|
||||
checksum(mallink *ml) {
|
||||
unsigned int sum = 0;
|
||||
size_type sum = 0;
|
||||
|
||||
if (free_of(ml)) {
|
||||
sum += (unsigned int)_log_prev_of(ml);
|
||||
sum += (unsigned int)_log_next_of(ml);
|
||||
sum += (size_type)_log_prev_of(ml);
|
||||
sum += (size_type)_log_next_of(ml);
|
||||
}
|
||||
sum += (unsigned int)prev_size_of(ml);
|
||||
sum += (unsigned int)_this_size_of(ml);
|
||||
sum += (size_type)prev_size_of(ml);
|
||||
sum += (size_type)_this_size_of(ml);
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
@ -284,6 +284,9 @@ check_work_empty(const char *s) {
|
|||
|
||||
private int
|
||||
Error(const char *fmt, const char *s, mallink *ml) {
|
||||
static int already_called = 0;
|
||||
|
||||
if (already_called++) return 0;
|
||||
setbuf(stdout, (char *) 0);
|
||||
printf("%s: ", s);
|
||||
printf(fmt, (long)ml);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
union _inf {
|
||||
union _inf *ptr;
|
||||
unsigned int ui;
|
||||
size_type ui;
|
||||
};
|
||||
|
||||
typedef union _inf mallink;
|
||||
|
@ -47,7 +47,7 @@ typedef union _inf mallink;
|
|||
#define N_WORDS 7
|
||||
#endif /* CHECK */
|
||||
|
||||
#define mallink_size() (unsigned int) \
|
||||
#define mallink_size() (size_t) \
|
||||
align((N_WORDS - OFF_SET) * sizeof (mallink))
|
||||
|
||||
#ifdef CHECK
|
||||
|
|
|
@ -21,7 +21,7 @@ link_free_chunk(register mallink *ml)
|
|||
chain.
|
||||
*/
|
||||
register mallink **mlp = &free_list[-1];
|
||||
register unsigned int n = size_of(ml);
|
||||
register size_type n = size_of(ml);
|
||||
register mallink *ml1;
|
||||
|
||||
assert(n < (1L << LOG_MAX_SIZE));
|
||||
|
@ -57,7 +57,7 @@ unlink_free_chunk(register mallink *ml)
|
|||
if (!prev) {
|
||||
/* it is the first in the chain */
|
||||
register mallink **mlp = &free_list[-1];
|
||||
register unsigned int n = size_of(ml);
|
||||
register size_type n = size_of(ml);
|
||||
|
||||
assert(n < (1L << LOG_MAX_SIZE));
|
||||
do {
|
||||
|
|
|
@ -96,11 +96,15 @@ malloc(register size_t n)
|
|||
SBRK((int) (align((size_type) p) - (size_type) p));
|
||||
}
|
||||
|
||||
p = SBRK((int)req);
|
||||
assert((size_type)p == align((size_type)p));
|
||||
/* SBRK takes an int; sorry ... */
|
||||
if ((int) req < 0) {
|
||||
p = ILL_BREAK;
|
||||
} else {
|
||||
p = SBRK((int)req);
|
||||
}
|
||||
if (p == ILL_BREAK) {
|
||||
req = n + mallink_size();
|
||||
p = SBRK((int)req);
|
||||
if ((int) req >= 0) p = SBRK((int)req);
|
||||
}
|
||||
if (p == ILL_BREAK) {
|
||||
/* Now this is bad. The system will not give us
|
||||
|
@ -128,6 +132,7 @@ malloc(register size_t n)
|
|||
#endif /* STORE */
|
||||
}
|
||||
else {
|
||||
assert((size_type)p == align((size_type)p));
|
||||
ml = create_chunk(p, req);
|
||||
}
|
||||
check_mallinks("suitable_chunk, extended");
|
||||
|
@ -235,7 +240,7 @@ void *
|
|||
realloc(void *addr, register size_t n)
|
||||
{check_mallinks("realloc entry");{
|
||||
register mallink *ml, *ph_next;
|
||||
register size_t size;
|
||||
register size_type size;
|
||||
|
||||
if (addr == NULL) {
|
||||
/* Behave like most Unix realloc's when handed a
|
||||
|
|
|
@ -16,9 +16,9 @@ publicdata mallink *ml_last;
|
|||
#define BITS (FREE_BIT)
|
||||
#endif
|
||||
|
||||
#define __bits(ml) ((size_type)_phys_prev_of(ml) & BITS)
|
||||
#define __free_of(ml) ((size_type)_phys_prev_of(ml) & FREE_BIT)
|
||||
#define __phys_prev_of(ml) (mallink *)((size_type)_phys_prev_of(ml) & ~BITS)
|
||||
#define __bits(ml) ((int)((size_type)_phys_prev_of(ml) & BITS))
|
||||
#define __free_of(ml) ((int)((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) - \
|
||||
(char *)__phys_prev_of(ml) - \
|
||||
mallink_size() \
|
||||
|
@ -49,7 +49,7 @@ public Error(const char *fmt, const char *s, mallink *ml);
|
|||
*/
|
||||
#define size_of(ml) (_this_size_of(ml) - mallink_size())
|
||||
#define set_phys_next(ml,e) \
|
||||
(_this_size_of(ml) = (unsigned int)((char *)(e) - (char *)(ml)))
|
||||
(_this_size_of(ml) = (size_type)((char *)(e) - (char *)(ml)))
|
||||
#define phys_next_of(ml) (mallink *) ((char *)(ml) + _this_size_of(ml))
|
||||
|
||||
#define set_free(ml,e) \
|
||||
|
|
Loading…
Reference in a new issue