bug fix: the in_store test did not work when NON_STANDARD was defined,
because in this case, the bit tested resided in user area
This commit is contained in:
parent
ac489d50a3
commit
5e2915d143
|
@ -9,9 +9,8 @@
|
|||
|
||||
#define MIN_SIZE (1<<LOG_MIN_SIZE)
|
||||
#define MAX_FLIST (LOG_MAX_SIZE - LOG_MIN_SIZE)
|
||||
#if ALIGNMENT != 1 && ALIGNMENT != 2 && ALIGNMENT != 4 && ALIGNMENT != 8 &&\
|
||||
ALIGNMENT != 16
|
||||
ALIGNMENT must be a (small) power of two !!!
|
||||
#if ALIGNMENT != 4 && ALIGNMENT != 8 && ALIGNMENT != 16
|
||||
ALIGNMENT must be 4, 8, or 16
|
||||
#endif
|
||||
#define align(n) (((n) + (ALIGNMENT - 1)) & ~(ALIGNMENT - 1))
|
||||
|
||||
|
|
|
@ -11,18 +11,14 @@ public link_free_chunk(), unlink_free_chunk();
|
|||
public mallink *first_present(), *search_free_list();
|
||||
|
||||
#ifdef STORE
|
||||
#define in_store(ml) ((size_type)_log_prev_of(ml) & 01)
|
||||
#define in_store(ml) ((size_type)_phys_prev_of(ml) & STORE_BIT)
|
||||
#define set_store(ml, e) \
|
||||
(_log_prev_of(ml) = (mallink *) \
|
||||
((e) ? (size_type) _log_prev_of(ml) | 01 : \
|
||||
(size_type) _log_prev_of(ml) & ~01))
|
||||
#define log_prev_of(ml) (mallink *)((size_type)_log_prev_of(ml) & ~01)
|
||||
#define set_log_prev(ml,e) \
|
||||
(_log_prev_of(ml) = (mallink *)((char *)e + in_store(ml)))
|
||||
#else
|
||||
(_phys_prev_of(ml) = (mallink *) \
|
||||
((e) ? (size_type) _phys_prev_of(ml) | STORE_BIT : \
|
||||
(size_type) _phys_prev_of(ml) & ~STORE_BIT))
|
||||
#endif
|
||||
#define set_log_prev(ml,e) (_log_prev_of(ml) = (e))
|
||||
#define log_prev_of(ml) (mallink *) (_log_prev_of(ml))
|
||||
#endif
|
||||
|
||||
#define set_log_next(ml,e) (_log_next_of(ml) = (e))
|
||||
#define log_next_of(ml) (mallink *) (_log_next_of(ml))
|
||||
|
|
|
@ -96,6 +96,7 @@ malloc(n)
|
|||
}
|
||||
|
||||
p = SBRK((int)req);
|
||||
assert((size_type)p == align((size_type)p));
|
||||
if (p == ILL_BREAK) {
|
||||
req = n + mallink_size();
|
||||
p = SBRK((int)req);
|
||||
|
|
|
@ -8,8 +8,17 @@
|
|||
*/
|
||||
publicdata mallink *ml_last;
|
||||
|
||||
#define __free_of(ml) ((size_type)_phys_prev_of(ml) & 01)
|
||||
#define __phys_prev_of(ml) (mallink *)((size_type)_phys_prev_of(ml) & ~01)
|
||||
#define FREE_BIT 01
|
||||
#ifdef STORE
|
||||
#define STORE_BIT 02
|
||||
#define BITS (FREE_BIT|STORE_BIT)
|
||||
#else
|
||||
#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) & ~FREE_BIT)
|
||||
#define prev_size_of(ml) ((char *)(ml) - \
|
||||
(char *)__phys_prev_of(ml) - \
|
||||
mallink_size() \
|
||||
|
@ -45,8 +54,8 @@ public Error();
|
|||
|
||||
#define set_free(ml,e) \
|
||||
(_phys_prev_of(ml) = (mallink *) \
|
||||
((e) ? (size_type) _phys_prev_of(ml) | 01 : \
|
||||
(size_type) _phys_prev_of(ml) & ~01))
|
||||
((e) ? (size_type) _phys_prev_of(ml) | FREE_BIT : \
|
||||
(size_type) _phys_prev_of(ml) & ~FREE_BIT))
|
||||
#define free_of(ml) (__free_of(ml))
|
||||
|
||||
#define coalesce_forw(ml,nxt) ( unlink_free_chunk(nxt), \
|
||||
|
|
Loading…
Reference in a new issue