summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--malloc/Makefile4
-rw-r--r--malloc/malloc.c4
2 files changed, 6 insertions, 2 deletions
diff --git a/malloc/Makefile b/malloc/Makefile
index dd8a43a6c7..e6ca11c76d 100644
--- a/malloc/Makefile
+++ b/malloc/Makefile
@@ -169,7 +169,9 @@ tst-malloc-usable-tunables-ENV = GLIBC_TUNABLES=glibc.malloc.check=3
tst-malloc-usable-static-tunables-ENV = $(tst-malloc-usable-tunables-ENV)
ifeq ($(experimental-malloc),yes)
-CPPFLAGS-malloc.c += -DUSE_TCACHE
+CPPFLAGS-malloc.c += -DUSE_TCACHE=1
+else
+CPPFLAGS-malloc.c += -DUSE_TCACHE=0
endif
# Uncomment this for test releases. For public releases it is too expensive.
#CPPFLAGS-malloc.o += -DMALLOC_DEBUG=1
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 91551ae1f2..d904db894e 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -2927,7 +2927,8 @@ typedef struct tcache_entry {
/* There is one of these for each thread, which contains the
per-thread cache (hence "tcache_perthread_struct"). Keeping
overall size low is mildly important. Note that COUNTS and ENTRIES
- are redundant, this is for performance reasons. */
+ are redundant (we could have just counted the linked list each
+ time), this is for performance reasons. */
typedef struct tcache_perthread_struct {
char counts[TCACHE_MAX_BINS];
tcache_entry *entries[TCACHE_MAX_BINS];
@@ -2955,6 +2956,7 @@ tcache_get (size_t tc_idx)
{
tcache_entry *e = tcache->entries[tc_idx];
assert (tc_idx < TCACHE_MAX_BINS);
+ assert (tcache->entries[tc_idx] > 0);
tcache->entries[tc_idx] = e->next;
--(tcache->counts[tc_idx]);
return (void *) e;