1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Aidan MacDonald 2022-03-30 18:23:59 +01:00
parent 3090cf0da4
commit 6e9b1b344b
3 changed files with 0 additions and 71 deletions

View file

@ -1068,52 +1068,6 @@ void buflib_check_valid(struct buflib_context *ctx)
} }
#endif #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 : "<unallocated>");
print(i++, buf);
}
}
#endif
#ifdef BUFLIB_DEBUG_BLOCK_SINGLE #ifdef BUFLIB_DEBUG_BLOCK_SINGLE
int buflib_get_num_blocks(struct buflib_context *ctx) int buflib_get_num_blocks(struct buflib_context *ctx)
{ {

View file

@ -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); 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 * Gets the number of blocks in the entire buffer, allocated or unallocated
* *

View file

@ -25,10 +25,6 @@ void core_check_valid(void);
/* DO NOT ADD wrappers for buflib_buffer_out/in. They do not call /* DO NOT ADD wrappers for buflib_buffer_out/in. They do not call
* the move callbacks and are therefore unsafe in the core */ * 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 #ifdef BUFLIB_DEBUG_BLOCK_SINGLE
int core_get_num_blocks(void); int core_get_num_blocks(void);
void core_print_block_at(int block_num, char* buf, size_t bufsize); void core_print_block_at(int block_num, char* buf, size_t bufsize);