From 6e9b1b344b7f7b04a2ae4ace0a1d191f63d03396 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Wed, 30 Mar 2022 18:23:59 +0100 Subject: buflib: remove buflib_print_allocs / buflib_print_blocks These don't have any users and there is already another way to print blocks (which is actually used by the debug menu). Change-Id: Ic6a4f874c6499c42bc046e8af3e4aaddc9e68276 --- firmware/buflib.c | 46 ------------------------------------------- firmware/include/buflib.h | 21 -------------------- firmware/include/core_alloc.h | 4 ---- 3 files changed, 71 deletions(-) diff --git a/firmware/buflib.c b/firmware/buflib.c index 2ed13b49b1..6bfc499235 100644 --- a/firmware/buflib.c +++ b/firmware/buflib.c @@ -1068,52 +1068,6 @@ void buflib_check_valid(struct buflib_context *ctx) } #endif -#ifdef BUFLIB_DEBUG_BLOCKS -void buflib_print_allocs(struct buflib_context *ctx, - void (*print)(int, const char*)) -{ - union buflib_data *this, *end = ctx->handle_table; - char buf[128]; - for(this = end - 1; this >= ctx->last_handle; this--) - { - if (!this->alloc) continue; - - int handle_num = end - this; - void* alloc_start = this->alloc; - union buflib_data *block_start = handle_to_block(ctx, handle_num); - const char* name = buflib_get_name(ctx, handle_num); - intptr_t alloc_len = block_start[fidx_LEN]; - - snprintf(buf, sizeof(buf), - "%s(%d):\t%p\n" - " \t%p\n" - " \t%ld\n", - name?:"(null)", handle_num, block_start, alloc_start, alloc_len); - /* handle_num is 1-based */ - print(handle_num - 1, buf); - } -} - -void buflib_print_blocks(struct buflib_context *ctx, - void (*print)(int, const char*)) -{ - char buf[128]; - int i = 0; - - for(union buflib_data *block = ctx->buf_start; - block != ctx->alloc_end; - block += abs(block->val)) - { - check_block_length(ctx, block); - - snprintf(buf, sizeof(buf), "%8p: val: %4ld (%s)", - block, (long)block->val, - block->val > 0 ? block[fidx_NAME].name : ""); - print(i++, buf); - } -} -#endif - #ifdef BUFLIB_DEBUG_BLOCK_SINGLE int buflib_get_num_blocks(struct buflib_context *ctx) { diff --git a/firmware/include/buflib.h b/firmware/include/buflib.h index 5bd8d73ada..a4796fbf33 100644 --- a/firmware/include/buflib.h +++ b/firmware/include/buflib.h @@ -341,27 +341,6 @@ void buflib_buffer_in(struct buflib_context *ctx, int size); */ const char* buflib_get_name(struct buflib_context *ctx, int handle); -/** - * Prints an overview of all current allocations with the help - * of the passed printer helper - * - * This walks only the handle table and prints only valid allocations - * - * Only available if BUFLIB_DEBUG_BLOCKS is defined - */ -void buflib_print_allocs(struct buflib_context *ctx, void (*print)(int, const char*)); - -/** - * Prints an overview of all blocks in the buflib buffer, allocated - * or unallocated, with the help of the passed printer helper - * - * This walks the entire buffer and prints unallocated space also. - * The output is also different from buflib_print_allocs(). - * - * Only available if BUFLIB_DEBUG_BLOCKS is defined - */ -void buflib_print_blocks(struct buflib_context *ctx, void (*print)(int, const char*)); - /** * Gets the number of blocks in the entire buffer, allocated or unallocated * diff --git a/firmware/include/core_alloc.h b/firmware/include/core_alloc.h index 67fe99dfdc..f535fc1f6e 100644 --- a/firmware/include/core_alloc.h +++ b/firmware/include/core_alloc.h @@ -25,10 +25,6 @@ void core_check_valid(void); /* DO NOT ADD wrappers for buflib_buffer_out/in. They do not call * the move callbacks and are therefore unsafe in the core */ -#ifdef BUFLIB_DEBUG_BLOCKS -void core_print_allocs(void (*print)(const char*)); -void core_print_blocks(void (*print)(const char*)); -#endif #ifdef BUFLIB_DEBUG_BLOCK_SINGLE int core_get_num_blocks(void); void core_print_block_at(int block_num, char* buf, size_t bufsize); -- cgit