/* Internal routines. */
static void* _int_malloc(mstate, size_t);
-static void _int_free (mstate, mchunkptr, int);
static void _int_free_check (mstate, mchunkptr, INTERNAL_SIZE_T);
static void _int_free_chunk (mstate, mchunkptr, INTERNAL_SIZE_T, int);
static void _int_free_merge_chunk (mstate, mchunkptr, INTERNAL_SIZE_T);
sysmalloc: Returns untagged memory.
_int_malloc: Returns untagged memory.
- _int_free: Takes untagged memory.
_int_memalign: Returns untagged memory.
_int_memalign: Returns untagged memory.
_mid_memalign: Returns tagged memory.
{
tcache_entry *e = (tcache_entry *) chunk2mem (chunk);
- /* Mark this chunk as "in the tcache" so the test in _int_free will
+ /* Mark this chunk as "in the tcache" so the test in __libc_free will
detect a double free. */
e->key = tcache_key;
void
__libc_free (void *mem)
{
- mstate ar_ptr;
mchunkptr p; /* chunk corresponding to mem */
if (mem == NULL) /* free(0) has no effect */
/* Mark the chunk as belonging to the library again. */
tag_region (chunk2mem (p), memsize (p));
- ar_ptr = arena_for_chunk (p);
- _int_free (ar_ptr, p, 0);
+ INTERNAL_SIZE_T size = chunksize (p);
+
+ _int_free_check (arena_for_chunk (p), p, size);
+
+#if USE_TCACHE
+ if (tcache_free (p, size))
+ return;
+#endif
+
+ _int_free_chunk (arena_for_chunk (p), p, size, 0);
}
libc_hidden_def (__libc_free)
}
}
-/* Free chunk P to its arena AV. HAVE_LOCK indicates where the arena for
- P has already been locked. It will perform sanity check, then try the
- fast path to free into tcache. If the attempt not success, free the
- chunk to arena. */
-static __always_inline void
-_int_free (mstate av, mchunkptr p, int have_lock)
-{
- INTERNAL_SIZE_T size; /* its size */
-
- size = chunksize (p);
-
- _int_free_check (av, p, size);
-
-#if USE_TCACHE
- if (tcache_free (p, size))
- return;
-#endif
-
- _int_free_chunk (av, p, size, have_lock);
-}
-
/* Try to merge chunk P of SIZE bytes with its neighbors. Put the
resulting chunk on the appropriate bin list. P must not be on a
bin list yet, and it can be in use. */