private acquire_malout(), check_ml_last();
private dump_all_mallinks(), dump_free_list(), dump_mallink(), print_loop();
private working_on();
-private unsigned int checksum();
+private size_type checksum();
static FILE *malout;
public mallink *free_list_entry();
for_free_list(i, ml) {
if (print_loop(ml))
return;
- fprintf(malout, "%ld ", ml);
+ fprintf(malout, "%ld ", (long) ml);
}
fprintf(malout, "<\n");
}
public
check_mallinks(s) char *s; {
mallink *ml;
- unsigned int size;
+ size_type size;
int i;
char stat;
Error("size of ml_last == 0, at %ld", s, ml_last);
}
-private unsigned int
+private size_type
checksum(ml) 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;
}
public int
Error(fmt, s, ml) char *fmt, *s; mallink *ml; {
+ static int already_called = 0;
+
+ if (already_called++) return 0;
setbuf(stdout, (char *) 0);
printf("%s: ", s);
printf(fmt, (long)ml);
union _inf {
union _inf *ptr;
- unsigned int ui;
+ size_type ui;
};
typedef union _inf mallink;
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));
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 {
SBRK((int) (align((size_type) p) - (size_type) p));
}
- p = SBRK((int)req);
+ /* 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
register unsigned int n;
{check_mallinks("realloc entry");{
register mallink *ml, *ph_next;
- register unsigned int size;
+ register size_type size;
if (addr == 0) {
/* Behave like most Unix realloc's when handed a
#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() \
*/
#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) \