From 1e9ad3ca0d9bf3e917eb2beb460421155144760a Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Sat, 15 Oct 2022 23:55:39 +0100 Subject: Remove buflib allocation names, part two Remove allocation names from the buflib API and fix up all callers. Change-Id: I3df922e258d5f0d711d70e72b56b4ed634fb0f5a --- apps/action.c | 2 +- apps/core_keymap.c | 2 +- apps/debug_menu.c | 2 +- apps/filetypes.c | 2 +- apps/gui/skin_engine/skin_backdrops.c | 5 ++--- apps/gui/skin_engine/skin_parser.c | 3 +-- apps/iap/iap-core.c | 2 +- apps/misc.c | 4 +--- apps/playback.c | 2 +- apps/playlist.c | 9 ++++----- apps/plugin.c | 4 +--- apps/plugin.h | 5 ++--- apps/radio/radioart.c | 2 +- apps/rbcodec_helpers.c | 2 +- apps/recorder/pcm_record.c | 2 +- apps/shortcuts.c | 9 +++------ apps/tagcache.c | 6 +++--- apps/tagtree.c | 2 +- apps/talk.c | 4 ++-- apps/tree.c | 9 +++------ apps/voice_thread.c | 2 +- 21 files changed, 33 insertions(+), 47 deletions(-) (limited to 'apps') diff --git a/apps/action.c b/apps/action.c index 20145a5bc1..208fea4a97 100644 --- a/apps/action.c +++ b/apps/action.c @@ -1202,7 +1202,7 @@ int action_set_keymap(struct button_mapping* core_keymap, int count) return action_set_keymap_handle(0, 0); size_t keyremap_buf_size = count * sizeof(struct button_mapping); - int handle = core_alloc("keyremap", keyremap_buf_size); + int handle = core_alloc(keyremap_buf_size); if (handle < 0) return -6; diff --git a/apps/core_keymap.c b/apps/core_keymap.c index 9d54fcffac..966f32057a 100644 --- a/apps/core_keymap.c +++ b/apps/core_keymap.c @@ -77,7 +77,7 @@ int core_load_key_remap(const char *filename) return -1; size_t bufsize = count * sizeof(struct button_mapping); - int handle = core_alloc("keyremap", bufsize); + int handle = core_alloc(bufsize); if (handle > 0) { core_pin(handle); diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 71c0395e6e..65b660813f 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -515,7 +515,7 @@ static int bf_action_cb(int action, struct gui_synclist* list) else { splash(HZ/1, "Attempting a 64k allocation"); - int handle = core_alloc("test", 64<<10); + int handle = core_alloc(64<<10); splash(HZ/2, (handle > 0) ? "Success":"Fail"); /* for some reason simplelist doesn't allow adding items here if * info.get_name is given, so use normal list api */ diff --git a/apps/filetypes.c b/apps/filetypes.c index 03f3cfa994..d5cfc379c1 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c @@ -409,7 +409,7 @@ static void read_viewers_config_init(void) /* estimate bufsize with the filesize, will not be larger */ strdup_bufsize = (size_t)filesz; - strdup_handle = core_alloc_ex("filetypes", strdup_bufsize, &ops); + strdup_handle = core_alloc_ex(strdup_bufsize, &ops); if(strdup_handle <= 0) goto out; diff --git a/apps/gui/skin_engine/skin_backdrops.c b/apps/gui/skin_engine/skin_backdrops.c index 8be40d1ce2..eecf5b0433 100644 --- a/apps/gui/skin_engine/skin_backdrops.c +++ b/apps/gui/skin_engine/skin_backdrops.c @@ -174,7 +174,7 @@ bool skin_backdrops_preload(void) } if (*filename && *filename != '-') { - backdrops[i].buflib_handle = core_alloc_ex(filename, buf_size, &buflib_ops); + backdrops[i].buflib_handle = core_alloc_ex(buf_size, &buflib_ops); if (backdrops[i].buflib_handle > 0) { backdrops[i].buffer = core_get_data(backdrops[i].buflib_handle); @@ -287,8 +287,7 @@ void skin_backdrop_load_setting(void) if (backdrops[i].buflib_handle <= 0) { backdrops[i].buflib_handle = - core_alloc_ex(global_settings.backdrop_file, - LCD_BACKDROP_BYTES, &buflib_ops); + core_alloc_ex(LCD_BACKDROP_BYTES, &buflib_ops); if (backdrops[i].buflib_handle <= 0) return; } diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index d99394eed0..6cc3c596b0 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -2574,8 +2574,7 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data, } #endif #ifndef __PCTOOL__ - wps_data->buflib_handle = core_alloc(isfile ? buf : "failsafe skin", - skin_buffer_usage()); + wps_data->buflib_handle = core_alloc(skin_buffer_usage()); if (wps_data->buflib_handle > 0) { wps_data->wps_loaded = true; diff --git a/apps/iap/iap-core.c b/apps/iap/iap-core.c index d2095b65bd..da04a67311 100644 --- a/apps/iap/iap-core.c +++ b/apps/iap/iap-core.c @@ -453,7 +453,7 @@ static void iap_malloc(void) return; #ifdef IAP_MALLOC_DYNAMIC - iap_buffer_handle = core_alloc_ex("iap", IAP_MALLOC_SIZE, &iap_buflib_callbacks); + iap_buffer_handle = core_alloc_ex(IAP_MALLOC_SIZE, &iap_buflib_callbacks); if (iap_buffer_handle < 0) panicf("Could not allocate buffer memory"); iap_buffers = core_get_data(iap_buffer_handle); diff --git a/apps/misc.c b/apps/misc.c index 36f45d46e0..93b5247ae9 100644 --- a/apps/misc.c +++ b/apps/misc.c @@ -1606,9 +1606,7 @@ int core_load_bmp(const char * filename, struct bitmap *bm, const int bmformat, if (buf_size > 0) { - - handle = core_alloc_ex(filename, (size_t) buf_size, ops); - + handle = core_alloc_ex(buf_size, ops); if (handle > 0) { core_pin(handle); diff --git a/apps/playback.c b/apps/playback.c index c4d84145b2..f298764a22 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -997,7 +997,7 @@ static void audio_reset_buffer(void) } if (core_allocatable() < (1 << 10)) talk_buffer_set_policy(TALK_BUFFER_LOOSE); /* back off voice buffer */ - audiobuf_handle = core_alloc_maximum("audiobuf", &filebuflen, &ops); + audiobuf_handle = core_alloc_maximum(&filebuflen, &ops); if (audiobuf_handle > 0) audio_reset_buffer_noalloc(core_get_data(audiobuf_handle)); diff --git a/apps/playlist.c b/apps/playlist.c index 25bd60dd2a..481524b9d4 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -2020,7 +2020,7 @@ static void alloc_namebuffer(void) static int alloc_tempbuf(size_t* buflen) { /* request a reasonable size first */ - int handle = core_alloc_ex(NULL, PLAYLIST_LOAD_BUFLEN, &buflib_ops_locked); + int handle = core_alloc_ex(PLAYLIST_LOAD_BUFLEN, &buflib_ops_locked); if (handle > 0) { *buflen = PLAYLIST_LOAD_BUFLEN; @@ -2028,7 +2028,7 @@ static int alloc_tempbuf(size_t* buflen) } /* otherwise, try being unreasonable */ - return core_alloc_maximum(NULL, buflen, &buflib_ops_locked); + return core_alloc_maximum(buflen, &buflib_ops_locked); } /* @@ -2075,15 +2075,14 @@ void playlist_init(void) playlist->fd = -1; playlist->control_fd = -1; playlist->max_playlist_size = global_settings.max_files_in_playlist; - handle = core_alloc_ex("playlist idx", - playlist->max_playlist_size * sizeof(*playlist->indices), &ops); + handle = core_alloc_ex(playlist->max_playlist_size * sizeof(*playlist->indices), &ops); playlist->indices = core_get_data(handle); initalize_new_playlist(playlist, true); #ifdef HAVE_DIRCACHE - handle = core_alloc_ex("playlist dc", + handle = core_alloc_ex( playlist->max_playlist_size * sizeof(*playlist->dcfrefs), &ops); playlist->dcfrefs = core_get_data(handle); dc_copy_filerefs(playlist->dcfrefs, NULL, playlist->max_playlist_size); diff --git a/apps/plugin.c b/apps/plugin.c index 7c6e91424a..38b7b6e821 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -585,7 +585,6 @@ static const struct plugin_api rockbox_api = { buflib_free, buflib_shrink, buflib_get_data, - buflib_get_name, /* sound */ sound_set, @@ -1039,8 +1038,7 @@ static void* plugin_get_audio_buffer(size_t *buffer_size) { if (plugin_buffer_handle <= 0) { - plugin_buffer_handle = core_alloc_maximum("plugin audio buf", - &plugin_buffer_size, + plugin_buffer_handle = core_alloc_maximum(&plugin_buffer_size, &buflib_ops_locked); } diff --git a/apps/plugin.h b/apps/plugin.h index 768fc0ff27..0e7e97433b 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -649,8 +649,8 @@ struct plugin_api { size_t (*buflib_available)(struct buflib_context* ctx); int (*buflib_alloc)(struct buflib_context* ctx, size_t size); int (*buflib_alloc_ex)(struct buflib_context* ctx, size_t size, - const char* name, struct buflib_callbacks *ops); - int (*buflib_alloc_maximum)(struct buflib_context* ctx, const char* name, + struct buflib_callbacks *ops); + int (*buflib_alloc_maximum)(struct buflib_context* ctx, size_t* size, struct buflib_callbacks *ops); void (*buflib_buffer_in)(struct buflib_context* ctx, int size); void* (*buflib_buffer_out)(struct buflib_context* ctx, size_t* size); @@ -658,7 +658,6 @@ struct plugin_api { bool (*buflib_shrink)(struct buflib_context* ctx, int handle, void* new_start, size_t new_size); void* (*buflib_get_data)(struct buflib_context* ctx, int handle); - const char* (*buflib_get_name)(struct buflib_context* ctx, int handle); /* sound */ void (*sound_set)(int setting, int value); diff --git a/apps/radio/radioart.c b/apps/radio/radioart.c index 230948c051..ce774ac4b1 100644 --- a/apps/radio/radioart.c +++ b/apps/radio/radioart.c @@ -202,7 +202,7 @@ void radioart_init(bool entering_screen) { /* grab control over buffering */ size_t bufsize; - int handle = core_alloc_maximum("radioart", &bufsize, &radioart_ops); + int handle = core_alloc_maximum(&bufsize, &radioart_ops); if (handle <0) { splash(HZ, "Radioart Failed - OOM"); diff --git a/apps/rbcodec_helpers.c b/apps/rbcodec_helpers.c index b856d7355d..197c0d4595 100644 --- a/apps/rbcodec_helpers.c +++ b/apps/rbcodec_helpers.c @@ -64,7 +64,7 @@ bool tdspeed_alloc_buffers(int32_t **buffers, const int *buf_s, int nbuf) { if (handles[i] <= 0) { - handles[i] = core_alloc_ex("tdspeed", buf_s[i], &ops); + handles[i] = core_alloc_ex(buf_s[i], &ops); if (handles[i] <= 0) return false; diff --git a/apps/recorder/pcm_record.c b/apps/recorder/pcm_record.c index f7f4c77928..8dc2c150fd 100644 --- a/apps/recorder/pcm_record.c +++ b/apps/recorder/pcm_record.c @@ -1408,7 +1408,7 @@ static void on_init_recording(void) send_event(RECORDING_EVENT_START, NULL); /* FIXME: This buffer should play nicer and be shrinkable/movable */ talk_buffer_set_policy(TALK_BUFFER_LOOSE); - pcmrec_handle = core_alloc_maximum("pcmrec", &rec_buffer_size, &buflib_ops_locked); + pcmrec_handle = core_alloc_maximum(&rec_buffer_size, &buflib_ops_locked); if (pcmrec_handle <= 0) /* someone is abusing core_alloc_maximum(). Fix this evil guy instead of * trying to handle OOM without hope */ diff --git a/apps/shortcuts.c b/apps/shortcuts.c index 3f13d0c1b3..2e10bad00f 100644 --- a/apps/shortcuts.c +++ b/apps/shortcuts.c @@ -128,8 +128,7 @@ static struct shortcut* get_shortcut(int index) if (first_handle == 0) { - first_handle = core_alloc_ex("shortcuts_head", - sizeof(struct shortcut_handle), &shortcut_ops); + first_handle = core_alloc_ex(sizeof(struct shortcut_handle), &shortcut_ops); if (first_handle <= 0) return NULL; h = core_get_data(first_handle); @@ -146,11 +145,9 @@ static struct shortcut* get_shortcut(int index) } while (handle_count > 0 && current_handle > 0); if (handle_count > 0 && handle_index == 0) { - char buf[32]; - snprintf(buf, sizeof buf, "shortcuts_%d", index/SHORTCUTS_PER_HANDLE); /* prevent invalidation of 'h' during compaction */ ++buflib_move_lock; - h->next_handle = core_alloc_ex(buf, sizeof(struct shortcut_handle), &shortcut_ops); + h->next_handle = core_alloc_ex(sizeof(struct shortcut_handle), &shortcut_ops); --buflib_move_lock; if (h->next_handle <= 0) return NULL; @@ -390,7 +387,7 @@ void shortcuts_init(void) fd = open_utf8(SHORTCUTS_FILENAME, O_RDONLY); if (fd < 0) return; - first_handle = core_alloc_ex("shortcuts_head", sizeof(struct shortcut_handle), &shortcut_ops); + first_handle = core_alloc_ex(sizeof(struct shortcut_handle), &shortcut_ops); if (first_handle <= 0) { close(fd); return; diff --git a/apps/tagcache.c b/apps/tagcache.c index c853c9d5e8..69a6eaade5 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -410,7 +410,7 @@ static void allocate_tempbuf(void) #else /* !__PCTOOL__ */ /* Need to pass dummy ops to prevent the buffer being moved * out from under us, since we yield during the tagcache commit. */ - tempbuf_handle = core_alloc_maximum("tc tempbuf", &size, &buflib_ops_locked); + tempbuf_handle = core_alloc_maximum(&size, &buflib_ops_locked); if (tempbuf_handle > 0) { tempbuf = core_get_data(tempbuf_handle); @@ -4115,7 +4115,7 @@ static bool allocate_tagcache(void) alloc_size += tcmh.tch.entry_count*sizeof(struct dircache_fileref); #endif - int handle = core_alloc_ex("tc ramcache", alloc_size, &ops); + int handle = core_alloc_ex(alloc_size, &ops); if (handle <= 0) return false; @@ -4158,7 +4158,7 @@ static bool tagcache_dumpload(void) } /* Lets allocate real memory and load it */ - handle = core_alloc_ex("tc ramcache", shdr.tc_stat.ramcache_allocated, &ops); + handle = core_alloc_ex(shdr.tc_stat.ramcache_allocated, &ops); if (handle <= 0) { logf("alloc failure"); diff --git a/apps/tagtree.c b/apps/tagtree.c index 03af5fc83a..10e63ae210 100644 --- a/apps/tagtree.c +++ b/apps/tagtree.c @@ -1255,7 +1255,7 @@ static bool initialize_tagtree(void) /* also used when user selects 'Reload' in menu_count = 0; menu = NULL; rootmenu = -1; - tagtree_handle = core_alloc_maximum("tagtree", &tagtree_bufsize, &ops); + tagtree_handle = core_alloc_maximum(&tagtree_bufsize, &ops); if (tagtree_handle < 0) panicf("tagtree OOM"); diff --git a/apps/talk.c b/apps/talk.c index 65368e973f..2ef7fea84d 100644 --- a/apps/talk.c +++ b/apps/talk.c @@ -496,7 +496,7 @@ static bool load_index_table(int fd, const struct voicefile_header *hdr) return true; ssize_t alloc_size = (hdr->id1_max + hdr->id2_max) * sizeof(struct clip_entry); - index_handle = core_alloc_ex("voice index", alloc_size, &talk_ops); + index_handle = core_alloc_ex(alloc_size, &talk_ops); if (index_handle < 0) return false; @@ -536,7 +536,7 @@ static bool load_header(int fd, struct voicefile_header *hdr) static bool create_clip_buffer(size_t max_size) { /* just allocate, populate on an as-needed basis later */ - talk_handle = core_alloc_ex("voice data", max_size, &talk_ops); + talk_handle = core_alloc_ex(max_size, &talk_ops); if (talk_handle < 0) goto alloc_err; diff --git a/apps/tree.c b/apps/tree.c index 22199710ae..d2a7111e5f 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -1063,14 +1063,11 @@ void tree_mem_init(void) cache->name_buffer_size = AVERAGE_FILENAME_LENGTH * global_settings.max_files_in_dir; - cache->name_buffer_handle = core_alloc_ex("tree names", - cache->name_buffer_size, - &ops); + cache->name_buffer_handle = core_alloc_ex(cache->name_buffer_size, &ops); cache->max_entries = global_settings.max_files_in_dir; - cache->entries_handle = core_alloc_ex("tree entries", - cache->max_entries*(sizeof(struct entry)), - &ops); + cache->entries_handle = + core_alloc_ex(cache->max_entries*(sizeof(struct entry)), &ops); } bool bookmark_play(char *resume_file, int index, unsigned long elapsed, diff --git a/apps/voice_thread.c b/apps/voice_thread.c index 6ce0f6a408..dfc2dd8ed6 100644 --- a/apps/voice_thread.c +++ b/apps/voice_thread.c @@ -569,7 +569,7 @@ void voice_thread_init(void) if (voice_thread_id != 0) return; /* Already did an init and succeeded at it */ - voice_buf_hid = core_alloc_ex("voice buf", sizeof (*voice_buf), &ops); + voice_buf_hid = core_alloc_ex(sizeof (*voice_buf), &ops); if (voice_buf_hid <= 0) { -- cgit v1.2.3