aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorArve Hjønnevåg <arve@android.com>2020-10-26 17:27:47 -0700
committerArve Hjønnevåg <arve@android.com>2020-10-26 18:26:07 -0700
commitbf522cff1dd0b28fe0056fa60b29c5e2577bff09 (patch)
tree8812658266603ece8babbe8e5556b6aa94ff80bf /lib
parentfa550f8d13e89de5681e411bf6b4b42c4cad4b03 (diff)
downloadcommon-bf522cff1dd0b28fe0056fa60b29c5e2577bff09.tar.gz
[lib][heap] Remove heap_delayed_free
It is no longer needed. Bug: 165825378 Change-Id: I0790cafca29072e0d93b396cd664c006571000ae
Diffstat (limited to 'lib')
-rw-r--r--lib/heap/heap_wrapper.c74
-rw-r--r--lib/heap/include/lib/heap.h3
2 files changed, 0 insertions, 77 deletions
diff --git a/lib/heap/heap_wrapper.c b/lib/heap/heap_wrapper.c
index d5e3025e..181dd6f5 100644
--- a/lib/heap/heap_wrapper.c
+++ b/lib/heap/heap_wrapper.c
@@ -42,10 +42,6 @@ static bool heap_trace = false;
#define heap_trace (false)
#endif
-/* delayed free list */
-struct list_node delayed_free_list = LIST_INITIAL_VALUE(delayed_free_list);
-spin_lock_t delayed_free_lock = SPIN_LOCK_INITIAL_VALUE;
-
#if WITH_LIB_HEAP_MINIHEAP
/* miniheap implementation */
#include <lib/miniheap.h>
@@ -135,27 +131,6 @@ static inline void HEAP_TRIM(void) { dlmalloc_trim(0); }
#error need to select valid heap implementation or provide wrapper
#endif
-static void heap_free_delayed_list(void)
-{
- struct list_node list;
-
- list_initialize(&list);
-
- spin_lock_saved_state_t state;
- spin_lock_irqsave(&delayed_free_lock, state);
-
- struct list_node *node;
- while ((node = list_remove_head(&delayed_free_list))) {
- list_add_head(&list, node);
- }
- spin_unlock_irqrestore(&delayed_free_lock, state);
-
- while ((node = list_remove_head(&list))) {
- LTRACEF("freeing node %p\n", node);
- HEAP_FREE(node);
- }
-}
-
void heap_init(void)
{
HEAP_INIT();
@@ -163,11 +138,6 @@ void heap_init(void)
void heap_trim(void)
{
- // deal with the pending free list
- if (unlikely(!list_is_empty(&delayed_free_list))) {
- heap_free_delayed_list();
- }
-
HEAP_TRIM();
}
@@ -175,11 +145,6 @@ void *malloc(size_t size)
{
LTRACEF("size %zd\n", size);
- // deal with the pending free list
- if (unlikely(!list_is_empty(&delayed_free_list))) {
- heap_free_delayed_list();
- }
-
void *ptr = HEAP_MALLOC(size);
if (heap_trace)
printf("caller %p malloc %zu -> %p\n", __GET_CALLER(), size, ptr);
@@ -190,11 +155,6 @@ void *memalign(size_t boundary, size_t size)
{
LTRACEF("boundary %zu, size %zd\n", boundary, size);
- // deal with the pending free list
- if (unlikely(!list_is_empty(&delayed_free_list))) {
- heap_free_delayed_list();
- }
-
void *ptr = HEAP_MEMALIGN(boundary, size);
if (heap_trace)
printf("caller %p memalign %zu, %zu -> %p\n", __GET_CALLER(), boundary, size, ptr);
@@ -205,11 +165,6 @@ void *calloc(size_t count, size_t size)
{
LTRACEF("count %zu, size %zd\n", count, size);
- // deal with the pending free list
- if (unlikely(!list_is_empty(&delayed_free_list))) {
- heap_free_delayed_list();
- }
-
void *ptr = HEAP_CALLOC(count, size);
if (heap_trace)
printf("caller %p calloc %zu, %zu -> %p\n", __GET_CALLER(), count, size, ptr);
@@ -220,11 +175,6 @@ void *realloc(void *ptr, size_t size)
{
LTRACEF("ptr %p, size %zd\n", ptr, size);
- // deal with the pending free list
- if (unlikely(!list_is_empty(&delayed_free_list))) {
- heap_free_delayed_list();
- }
-
void *ptr2 = HEAP_REALLOC(ptr, size);
if (heap_trace)
printf("caller %p realloc %p, %zu -> %p\n", __GET_CALLER(), ptr, size, ptr2);
@@ -240,33 +190,9 @@ void free(void *ptr)
HEAP_FREE(ptr);
}
-/* critical section time delayed free */
-void heap_delayed_free(void *ptr)
-{
- LTRACEF("ptr %p\n", ptr);
-
- /* throw down a structure on the free block */
- /* XXX assumes the free block is large enough to hold a list node */
- struct list_node *node = (struct list_node *)ptr;
-
- spin_lock_saved_state_t state;
- spin_lock_irqsave(&delayed_free_lock, state);
- list_add_head(&delayed_free_list, node);
- spin_unlock_irqrestore(&delayed_free_lock, state);
-}
-
static void heap_dump(void)
{
HEAP_DUMP();
-
- printf("\tdelayed free list:\n");
- spin_lock_saved_state_t state;
- spin_lock_irqsave(&delayed_free_lock, state);
- struct list_node *node;
- list_for_every(&delayed_free_list, node) {
- printf("\t\tnode %p\n", node);
- }
- spin_unlock_irqrestore(&delayed_free_lock, state);
}
static void heap_test(void)
diff --git a/lib/heap/include/lib/heap.h b/lib/heap/include/lib/heap.h
index bcaea7af..7f5cde7f 100644
--- a/lib/heap/include/lib/heap.h
+++ b/lib/heap/include/lib/heap.h
@@ -37,9 +37,6 @@ void free(void *ptr);
void heap_init(void);
-/* critical section time delayed free */
-void heap_delayed_free(void *);
-
/* tell the heap to return any free pages it can find */
void heap_trim(void);