diff options
author | Rich Felker <dalias@aerifal.cx> | 2011-11-16 23:59:28 -0500 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2011-11-16 23:59:28 -0500 |
commit | e5d78fe8df9bd61940abcd98ad07ed69b7da4350 (patch) | |
tree | 487e681d1f13d0fab839d7a78b944828bed31e61 | |
parent | 4e3df7be8ff430de6f0f124a20112fb7be8a17d0 (diff) | |
download | musl-e5d78fe8df9bd61940abcd98ad07ed69b7da4350.tar.gz musl-e5d78fe8df9bd61940abcd98ad07ed69b7da4350.tar.xz musl-e5d78fe8df9bd61940abcd98ad07ed69b7da4350.zip |
fix issue with excessive mremap syscalls on realloc
CHUNK_SIZE macro was defined incorrectly and shaving off at least one significant bit in the size of mmapped chunks, resulting in the test for oldlen==newlen always failing and incurring a syscall. fortunately i don't think this issue caused any other observable behavior; the definition worked correctly for all non-mmapped chunks where its correctness matters more, since their lengths are always multiples of the alignment.
-rw-r--r-- | src/malloc/malloc.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/malloc/malloc.c b/src/malloc/malloc.c index abf3e8fa..39c7d051 100644 --- a/src/malloc/malloc.c +++ b/src/malloc/malloc.c @@ -43,8 +43,8 @@ static struct { #define DONTCARE 16 #define RECLAIM 163840 -#define CHUNK_SIZE(c) ((c)->csize & SIZE_MASK) -#define CHUNK_PSIZE(c) ((c)->psize & SIZE_MASK) +#define CHUNK_SIZE(c) ((c)->csize & -2) +#define CHUNK_PSIZE(c) ((c)->psize & -2) #define PREV_CHUNK(c) ((struct chunk *)((char *)(c) - CHUNK_PSIZE(c))) #define NEXT_CHUNK(c) ((struct chunk *)((char *)(c) + CHUNK_SIZE(c))) #define MEM_TO_CHUNK(p) (struct chunk *)((char *)(p) - OVERHEAD) @@ -52,8 +52,6 @@ static struct { #define BIN_TO_CHUNK(i) (MEM_TO_CHUNK(&mal.bins[i].head)) #define C_INUSE ((size_t)1) -#define C_FLAGS ((size_t)3) -#define C_SIZE SIZE_MASK #define IS_MMAPPED(c) !((c)->csize & (C_INUSE)) |