diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2022-10-15 23:55:39 +0100 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2023-01-13 10:32:54 +0000 |
commit | 1e9ad3ca0d9bf3e917eb2beb460421155144760a (patch) | |
tree | 752590b42f338f03223e024fc5b642ac9a8a5598 | |
parent | 3301c5aa6db76832dbb9af8f72d29b348190fd91 (diff) | |
download | rockbox-1e9ad3ca0d9bf3e917eb2beb460421155144760a.tar.gz rockbox-1e9ad3ca0d9bf3e917eb2beb460421155144760a.zip |
Remove buflib allocation names, part two
Remove allocation names from the buflib API and fix up all callers.
Change-Id: I3df922e258d5f0d711d70e72b56b4ed634fb0f5a
39 files changed, 69 insertions, 115 deletions
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) | |||
1202 | return action_set_keymap_handle(0, 0); | 1202 | return action_set_keymap_handle(0, 0); |
1203 | 1203 | ||
1204 | size_t keyremap_buf_size = count * sizeof(struct button_mapping); | 1204 | size_t keyremap_buf_size = count * sizeof(struct button_mapping); |
1205 | int handle = core_alloc("keyremap", keyremap_buf_size); | 1205 | int handle = core_alloc(keyremap_buf_size); |
1206 | if (handle < 0) | 1206 | if (handle < 0) |
1207 | return -6; | 1207 | return -6; |
1208 | 1208 | ||
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) | |||
77 | return -1; | 77 | return -1; |
78 | 78 | ||
79 | size_t bufsize = count * sizeof(struct button_mapping); | 79 | size_t bufsize = count * sizeof(struct button_mapping); |
80 | int handle = core_alloc("keyremap", bufsize); | 80 | int handle = core_alloc(bufsize); |
81 | if (handle > 0) | 81 | if (handle > 0) |
82 | { | 82 | { |
83 | core_pin(handle); | 83 | 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) | |||
515 | else | 515 | else |
516 | { | 516 | { |
517 | splash(HZ/1, "Attempting a 64k allocation"); | 517 | splash(HZ/1, "Attempting a 64k allocation"); |
518 | int handle = core_alloc("test", 64<<10); | 518 | int handle = core_alloc(64<<10); |
519 | splash(HZ/2, (handle > 0) ? "Success":"Fail"); | 519 | splash(HZ/2, (handle > 0) ? "Success":"Fail"); |
520 | /* for some reason simplelist doesn't allow adding items here if | 520 | /* for some reason simplelist doesn't allow adding items here if |
521 | * info.get_name is given, so use normal list api */ | 521 | * 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) | |||
409 | 409 | ||
410 | /* estimate bufsize with the filesize, will not be larger */ | 410 | /* estimate bufsize with the filesize, will not be larger */ |
411 | strdup_bufsize = (size_t)filesz; | 411 | strdup_bufsize = (size_t)filesz; |
412 | strdup_handle = core_alloc_ex("filetypes", strdup_bufsize, &ops); | 412 | strdup_handle = core_alloc_ex(strdup_bufsize, &ops); |
413 | if(strdup_handle <= 0) | 413 | if(strdup_handle <= 0) |
414 | goto out; | 414 | goto out; |
415 | 415 | ||
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) | |||
174 | } | 174 | } |
175 | if (*filename && *filename != '-') | 175 | if (*filename && *filename != '-') |
176 | { | 176 | { |
177 | backdrops[i].buflib_handle = core_alloc_ex(filename, buf_size, &buflib_ops); | 177 | backdrops[i].buflib_handle = core_alloc_ex(buf_size, &buflib_ops); |
178 | if (backdrops[i].buflib_handle > 0) | 178 | if (backdrops[i].buflib_handle > 0) |
179 | { | 179 | { |
180 | backdrops[i].buffer = core_get_data(backdrops[i].buflib_handle); | 180 | backdrops[i].buffer = core_get_data(backdrops[i].buflib_handle); |
@@ -287,8 +287,7 @@ void skin_backdrop_load_setting(void) | |||
287 | if (backdrops[i].buflib_handle <= 0) | 287 | if (backdrops[i].buflib_handle <= 0) |
288 | { | 288 | { |
289 | backdrops[i].buflib_handle = | 289 | backdrops[i].buflib_handle = |
290 | core_alloc_ex(global_settings.backdrop_file, | 290 | core_alloc_ex(LCD_BACKDROP_BYTES, &buflib_ops); |
291 | LCD_BACKDROP_BYTES, &buflib_ops); | ||
292 | if (backdrops[i].buflib_handle <= 0) | 291 | if (backdrops[i].buflib_handle <= 0) |
293 | return; | 292 | return; |
294 | } | 293 | } |
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, | |||
2574 | } | 2574 | } |
2575 | #endif | 2575 | #endif |
2576 | #ifndef __PCTOOL__ | 2576 | #ifndef __PCTOOL__ |
2577 | wps_data->buflib_handle = core_alloc(isfile ? buf : "failsafe skin", | 2577 | wps_data->buflib_handle = core_alloc(skin_buffer_usage()); |
2578 | skin_buffer_usage()); | ||
2579 | if (wps_data->buflib_handle > 0) | 2578 | if (wps_data->buflib_handle > 0) |
2580 | { | 2579 | { |
2581 | wps_data->wps_loaded = true; | 2580 | 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) | |||
453 | return; | 453 | return; |
454 | 454 | ||
455 | #ifdef IAP_MALLOC_DYNAMIC | 455 | #ifdef IAP_MALLOC_DYNAMIC |
456 | iap_buffer_handle = core_alloc_ex("iap", IAP_MALLOC_SIZE, &iap_buflib_callbacks); | 456 | iap_buffer_handle = core_alloc_ex(IAP_MALLOC_SIZE, &iap_buflib_callbacks); |
457 | if (iap_buffer_handle < 0) | 457 | if (iap_buffer_handle < 0) |
458 | panicf("Could not allocate buffer memory"); | 458 | panicf("Could not allocate buffer memory"); |
459 | iap_buffers = core_get_data(iap_buffer_handle); | 459 | 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, | |||
1606 | 1606 | ||
1607 | if (buf_size > 0) | 1607 | if (buf_size > 0) |
1608 | { | 1608 | { |
1609 | 1609 | handle = core_alloc_ex(buf_size, ops); | |
1610 | handle = core_alloc_ex(filename, (size_t) buf_size, ops); | ||
1611 | |||
1612 | if (handle > 0) | 1610 | if (handle > 0) |
1613 | { | 1611 | { |
1614 | core_pin(handle); | 1612 | 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) | |||
997 | } | 997 | } |
998 | if (core_allocatable() < (1 << 10)) | 998 | if (core_allocatable() < (1 << 10)) |
999 | talk_buffer_set_policy(TALK_BUFFER_LOOSE); /* back off voice buffer */ | 999 | talk_buffer_set_policy(TALK_BUFFER_LOOSE); /* back off voice buffer */ |
1000 | audiobuf_handle = core_alloc_maximum("audiobuf", &filebuflen, &ops); | 1000 | audiobuf_handle = core_alloc_maximum(&filebuflen, &ops); |
1001 | 1001 | ||
1002 | if (audiobuf_handle > 0) | 1002 | if (audiobuf_handle > 0) |
1003 | audio_reset_buffer_noalloc(core_get_data(audiobuf_handle)); | 1003 | 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) | |||
2020 | static int alloc_tempbuf(size_t* buflen) | 2020 | static int alloc_tempbuf(size_t* buflen) |
2021 | { | 2021 | { |
2022 | /* request a reasonable size first */ | 2022 | /* request a reasonable size first */ |
2023 | int handle = core_alloc_ex(NULL, PLAYLIST_LOAD_BUFLEN, &buflib_ops_locked); | 2023 | int handle = core_alloc_ex(PLAYLIST_LOAD_BUFLEN, &buflib_ops_locked); |
2024 | if (handle > 0) | 2024 | if (handle > 0) |
2025 | { | 2025 | { |
2026 | *buflen = PLAYLIST_LOAD_BUFLEN; | 2026 | *buflen = PLAYLIST_LOAD_BUFLEN; |
@@ -2028,7 +2028,7 @@ static int alloc_tempbuf(size_t* buflen) | |||
2028 | } | 2028 | } |
2029 | 2029 | ||
2030 | /* otherwise, try being unreasonable */ | 2030 | /* otherwise, try being unreasonable */ |
2031 | return core_alloc_maximum(NULL, buflen, &buflib_ops_locked); | 2031 | return core_alloc_maximum(buflen, &buflib_ops_locked); |
2032 | } | 2032 | } |
2033 | 2033 | ||
2034 | /* | 2034 | /* |
@@ -2075,15 +2075,14 @@ void playlist_init(void) | |||
2075 | playlist->fd = -1; | 2075 | playlist->fd = -1; |
2076 | playlist->control_fd = -1; | 2076 | playlist->control_fd = -1; |
2077 | playlist->max_playlist_size = global_settings.max_files_in_playlist; | 2077 | playlist->max_playlist_size = global_settings.max_files_in_playlist; |
2078 | handle = core_alloc_ex("playlist idx", | ||
2079 | playlist->max_playlist_size * sizeof(*playlist->indices), &ops); | ||
2080 | 2078 | ||
2079 | handle = core_alloc_ex(playlist->max_playlist_size * sizeof(*playlist->indices), &ops); | ||
2081 | playlist->indices = core_get_data(handle); | 2080 | playlist->indices = core_get_data(handle); |
2082 | 2081 | ||
2083 | initalize_new_playlist(playlist, true); | 2082 | initalize_new_playlist(playlist, true); |
2084 | 2083 | ||
2085 | #ifdef HAVE_DIRCACHE | 2084 | #ifdef HAVE_DIRCACHE |
2086 | handle = core_alloc_ex("playlist dc", | 2085 | handle = core_alloc_ex( |
2087 | playlist->max_playlist_size * sizeof(*playlist->dcfrefs), &ops); | 2086 | playlist->max_playlist_size * sizeof(*playlist->dcfrefs), &ops); |
2088 | playlist->dcfrefs = core_get_data(handle); | 2087 | playlist->dcfrefs = core_get_data(handle); |
2089 | dc_copy_filerefs(playlist->dcfrefs, NULL, playlist->max_playlist_size); | 2088 | 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 = { | |||
585 | buflib_free, | 585 | buflib_free, |
586 | buflib_shrink, | 586 | buflib_shrink, |
587 | buflib_get_data, | 587 | buflib_get_data, |
588 | buflib_get_name, | ||
589 | 588 | ||
590 | /* sound */ | 589 | /* sound */ |
591 | sound_set, | 590 | sound_set, |
@@ -1039,8 +1038,7 @@ static void* plugin_get_audio_buffer(size_t *buffer_size) | |||
1039 | { | 1038 | { |
1040 | if (plugin_buffer_handle <= 0) | 1039 | if (plugin_buffer_handle <= 0) |
1041 | { | 1040 | { |
1042 | plugin_buffer_handle = core_alloc_maximum("plugin audio buf", | 1041 | plugin_buffer_handle = core_alloc_maximum(&plugin_buffer_size, |
1043 | &plugin_buffer_size, | ||
1044 | &buflib_ops_locked); | 1042 | &buflib_ops_locked); |
1045 | } | 1043 | } |
1046 | 1044 | ||
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 { | |||
649 | size_t (*buflib_available)(struct buflib_context* ctx); | 649 | size_t (*buflib_available)(struct buflib_context* ctx); |
650 | int (*buflib_alloc)(struct buflib_context* ctx, size_t size); | 650 | int (*buflib_alloc)(struct buflib_context* ctx, size_t size); |
651 | int (*buflib_alloc_ex)(struct buflib_context* ctx, size_t size, | 651 | int (*buflib_alloc_ex)(struct buflib_context* ctx, size_t size, |
652 | const char* name, struct buflib_callbacks *ops); | 652 | struct buflib_callbacks *ops); |
653 | int (*buflib_alloc_maximum)(struct buflib_context* ctx, const char* name, | 653 | int (*buflib_alloc_maximum)(struct buflib_context* ctx, |
654 | size_t* size, struct buflib_callbacks *ops); | 654 | size_t* size, struct buflib_callbacks *ops); |
655 | void (*buflib_buffer_in)(struct buflib_context* ctx, int size); | 655 | void (*buflib_buffer_in)(struct buflib_context* ctx, int size); |
656 | void* (*buflib_buffer_out)(struct buflib_context* ctx, size_t* size); | 656 | void* (*buflib_buffer_out)(struct buflib_context* ctx, size_t* size); |
@@ -658,7 +658,6 @@ struct plugin_api { | |||
658 | bool (*buflib_shrink)(struct buflib_context* ctx, int handle, | 658 | bool (*buflib_shrink)(struct buflib_context* ctx, int handle, |
659 | void* new_start, size_t new_size); | 659 | void* new_start, size_t new_size); |
660 | void* (*buflib_get_data)(struct buflib_context* ctx, int handle); | 660 | void* (*buflib_get_data)(struct buflib_context* ctx, int handle); |
661 | const char* (*buflib_get_name)(struct buflib_context* ctx, int handle); | ||
662 | 661 | ||
663 | /* sound */ | 662 | /* sound */ |
664 | void (*sound_set)(int setting, int value); | 663 | 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) | |||
202 | { | 202 | { |
203 | /* grab control over buffering */ | 203 | /* grab control over buffering */ |
204 | size_t bufsize; | 204 | size_t bufsize; |
205 | int handle = core_alloc_maximum("radioart", &bufsize, &radioart_ops); | 205 | int handle = core_alloc_maximum(&bufsize, &radioart_ops); |
206 | if (handle <0) | 206 | if (handle <0) |
207 | { | 207 | { |
208 | splash(HZ, "Radioart Failed - OOM"); | 208 | 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) | |||
64 | { | 64 | { |
65 | if (handles[i] <= 0) | 65 | if (handles[i] <= 0) |
66 | { | 66 | { |
67 | handles[i] = core_alloc_ex("tdspeed", buf_s[i], &ops); | 67 | handles[i] = core_alloc_ex(buf_s[i], &ops); |
68 | 68 | ||
69 | if (handles[i] <= 0) | 69 | if (handles[i] <= 0) |
70 | return false; | 70 | 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) | |||
1408 | send_event(RECORDING_EVENT_START, NULL); | 1408 | send_event(RECORDING_EVENT_START, NULL); |
1409 | /* FIXME: This buffer should play nicer and be shrinkable/movable */ | 1409 | /* FIXME: This buffer should play nicer and be shrinkable/movable */ |
1410 | talk_buffer_set_policy(TALK_BUFFER_LOOSE); | 1410 | talk_buffer_set_policy(TALK_BUFFER_LOOSE); |
1411 | pcmrec_handle = core_alloc_maximum("pcmrec", &rec_buffer_size, &buflib_ops_locked); | 1411 | pcmrec_handle = core_alloc_maximum(&rec_buffer_size, &buflib_ops_locked); |
1412 | if (pcmrec_handle <= 0) | 1412 | if (pcmrec_handle <= 0) |
1413 | /* someone is abusing core_alloc_maximum(). Fix this evil guy instead of | 1413 | /* someone is abusing core_alloc_maximum(). Fix this evil guy instead of |
1414 | * trying to handle OOM without hope */ | 1414 | * 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) | |||
128 | 128 | ||
129 | if (first_handle == 0) | 129 | if (first_handle == 0) |
130 | { | 130 | { |
131 | first_handle = core_alloc_ex("shortcuts_head", | 131 | first_handle = core_alloc_ex(sizeof(struct shortcut_handle), &shortcut_ops); |
132 | sizeof(struct shortcut_handle), &shortcut_ops); | ||
133 | if (first_handle <= 0) | 132 | if (first_handle <= 0) |
134 | return NULL; | 133 | return NULL; |
135 | h = core_get_data(first_handle); | 134 | h = core_get_data(first_handle); |
@@ -146,11 +145,9 @@ static struct shortcut* get_shortcut(int index) | |||
146 | } while (handle_count > 0 && current_handle > 0); | 145 | } while (handle_count > 0 && current_handle > 0); |
147 | if (handle_count > 0 && handle_index == 0) | 146 | if (handle_count > 0 && handle_index == 0) |
148 | { | 147 | { |
149 | char buf[32]; | ||
150 | snprintf(buf, sizeof buf, "shortcuts_%d", index/SHORTCUTS_PER_HANDLE); | ||
151 | /* prevent invalidation of 'h' during compaction */ | 148 | /* prevent invalidation of 'h' during compaction */ |
152 | ++buflib_move_lock; | 149 | ++buflib_move_lock; |
153 | h->next_handle = core_alloc_ex(buf, sizeof(struct shortcut_handle), &shortcut_ops); | 150 | h->next_handle = core_alloc_ex(sizeof(struct shortcut_handle), &shortcut_ops); |
154 | --buflib_move_lock; | 151 | --buflib_move_lock; |
155 | if (h->next_handle <= 0) | 152 | if (h->next_handle <= 0) |
156 | return NULL; | 153 | return NULL; |
@@ -390,7 +387,7 @@ void shortcuts_init(void) | |||
390 | fd = open_utf8(SHORTCUTS_FILENAME, O_RDONLY); | 387 | fd = open_utf8(SHORTCUTS_FILENAME, O_RDONLY); |
391 | if (fd < 0) | 388 | if (fd < 0) |
392 | return; | 389 | return; |
393 | first_handle = core_alloc_ex("shortcuts_head", sizeof(struct shortcut_handle), &shortcut_ops); | 390 | first_handle = core_alloc_ex(sizeof(struct shortcut_handle), &shortcut_ops); |
394 | if (first_handle <= 0) { | 391 | if (first_handle <= 0) { |
395 | close(fd); | 392 | close(fd); |
396 | return; | 393 | 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) | |||
410 | #else /* !__PCTOOL__ */ | 410 | #else /* !__PCTOOL__ */ |
411 | /* Need to pass dummy ops to prevent the buffer being moved | 411 | /* Need to pass dummy ops to prevent the buffer being moved |
412 | * out from under us, since we yield during the tagcache commit. */ | 412 | * out from under us, since we yield during the tagcache commit. */ |
413 | tempbuf_handle = core_alloc_maximum("tc tempbuf", &size, &buflib_ops_locked); | 413 | tempbuf_handle = core_alloc_maximum(&size, &buflib_ops_locked); |
414 | if (tempbuf_handle > 0) | 414 | if (tempbuf_handle > 0) |
415 | { | 415 | { |
416 | tempbuf = core_get_data(tempbuf_handle); | 416 | tempbuf = core_get_data(tempbuf_handle); |
@@ -4115,7 +4115,7 @@ static bool allocate_tagcache(void) | |||
4115 | alloc_size += tcmh.tch.entry_count*sizeof(struct dircache_fileref); | 4115 | alloc_size += tcmh.tch.entry_count*sizeof(struct dircache_fileref); |
4116 | #endif | 4116 | #endif |
4117 | 4117 | ||
4118 | int handle = core_alloc_ex("tc ramcache", alloc_size, &ops); | 4118 | int handle = core_alloc_ex(alloc_size, &ops); |
4119 | if (handle <= 0) | 4119 | if (handle <= 0) |
4120 | return false; | 4120 | return false; |
4121 | 4121 | ||
@@ -4158,7 +4158,7 @@ static bool tagcache_dumpload(void) | |||
4158 | } | 4158 | } |
4159 | 4159 | ||
4160 | /* Lets allocate real memory and load it */ | 4160 | /* Lets allocate real memory and load it */ |
4161 | handle = core_alloc_ex("tc ramcache", shdr.tc_stat.ramcache_allocated, &ops); | 4161 | handle = core_alloc_ex(shdr.tc_stat.ramcache_allocated, &ops); |
4162 | if (handle <= 0) | 4162 | if (handle <= 0) |
4163 | { | 4163 | { |
4164 | logf("alloc failure"); | 4164 | 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 | |||
1255 | menu_count = 0; | 1255 | menu_count = 0; |
1256 | menu = NULL; | 1256 | menu = NULL; |
1257 | rootmenu = -1; | 1257 | rootmenu = -1; |
1258 | tagtree_handle = core_alloc_maximum("tagtree", &tagtree_bufsize, &ops); | 1258 | tagtree_handle = core_alloc_maximum(&tagtree_bufsize, &ops); |
1259 | if (tagtree_handle < 0) | 1259 | if (tagtree_handle < 0) |
1260 | panicf("tagtree OOM"); | 1260 | panicf("tagtree OOM"); |
1261 | 1261 | ||
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) | |||
496 | return true; | 496 | return true; |
497 | 497 | ||
498 | ssize_t alloc_size = (hdr->id1_max + hdr->id2_max) * sizeof(struct clip_entry); | 498 | ssize_t alloc_size = (hdr->id1_max + hdr->id2_max) * sizeof(struct clip_entry); |
499 | index_handle = core_alloc_ex("voice index", alloc_size, &talk_ops); | 499 | index_handle = core_alloc_ex(alloc_size, &talk_ops); |
500 | if (index_handle < 0) | 500 | if (index_handle < 0) |
501 | return false; | 501 | return false; |
502 | 502 | ||
@@ -536,7 +536,7 @@ static bool load_header(int fd, struct voicefile_header *hdr) | |||
536 | static bool create_clip_buffer(size_t max_size) | 536 | static bool create_clip_buffer(size_t max_size) |
537 | { | 537 | { |
538 | /* just allocate, populate on an as-needed basis later */ | 538 | /* just allocate, populate on an as-needed basis later */ |
539 | talk_handle = core_alloc_ex("voice data", max_size, &talk_ops); | 539 | talk_handle = core_alloc_ex(max_size, &talk_ops); |
540 | if (talk_handle < 0) | 540 | if (talk_handle < 0) |
541 | goto alloc_err; | 541 | goto alloc_err; |
542 | 542 | ||
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) | |||
1063 | 1063 | ||
1064 | cache->name_buffer_size = AVERAGE_FILENAME_LENGTH * | 1064 | cache->name_buffer_size = AVERAGE_FILENAME_LENGTH * |
1065 | global_settings.max_files_in_dir; | 1065 | global_settings.max_files_in_dir; |
1066 | cache->name_buffer_handle = core_alloc_ex("tree names", | 1066 | cache->name_buffer_handle = core_alloc_ex(cache->name_buffer_size, &ops); |
1067 | cache->name_buffer_size, | ||
1068 | &ops); | ||
1069 | 1067 | ||
1070 | cache->max_entries = global_settings.max_files_in_dir; | 1068 | cache->max_entries = global_settings.max_files_in_dir; |
1071 | cache->entries_handle = core_alloc_ex("tree entries", | 1069 | cache->entries_handle = |
1072 | cache->max_entries*(sizeof(struct entry)), | 1070 | core_alloc_ex(cache->max_entries*(sizeof(struct entry)), &ops); |
1073 | &ops); | ||
1074 | } | 1071 | } |
1075 | 1072 | ||
1076 | bool bookmark_play(char *resume_file, int index, unsigned long elapsed, | 1073 | 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) | |||
569 | if (voice_thread_id != 0) | 569 | if (voice_thread_id != 0) |
570 | return; /* Already did an init and succeeded at it */ | 570 | return; /* Already did an init and succeeded at it */ |
571 | 571 | ||
572 | voice_buf_hid = core_alloc_ex("voice buf", sizeof (*voice_buf), &ops); | 572 | voice_buf_hid = core_alloc_ex(sizeof (*voice_buf), &ops); |
573 | 573 | ||
574 | if (voice_buf_hid <= 0) | 574 | if (voice_buf_hid <= 0) |
575 | { | 575 | { |
diff --git a/bootloader/x1000/boot.c b/bootloader/x1000/boot.c index 9e22192516..8b44641604 100644 --- a/bootloader/x1000/boot.c +++ b/bootloader/x1000/boot.c | |||
@@ -72,7 +72,7 @@ static int read_linux_args(const char* filename) | |||
72 | int ret; | 72 | int ret; |
73 | 73 | ||
74 | size_t max_size; | 74 | size_t max_size; |
75 | int handle = core_alloc_maximum("args", &max_size, &buflib_ops_locked); | 75 | int handle = core_alloc_maximum(&max_size, &buflib_ops_locked); |
76 | if(handle <= 0) { | 76 | if(handle <= 0) { |
77 | splashf(5*HZ, "Out of memory"); | 77 | splashf(5*HZ, "Out of memory"); |
78 | return -2; | 78 | return -2; |
diff --git a/bootloader/x1000/utils.c b/bootloader/x1000/utils.c index a2fd500f5d..8d296b234b 100644 --- a/bootloader/x1000/utils.c +++ b/bootloader/x1000/utils.c | |||
@@ -103,7 +103,7 @@ int load_rockbox(const char* filename, size_t* sizep) | |||
103 | if(check_disk(true) != DISK_PRESENT) | 103 | if(check_disk(true) != DISK_PRESENT) |
104 | return -1; | 104 | return -1; |
105 | 105 | ||
106 | int handle = core_alloc_maximum("rockbox", sizep, &buflib_ops_locked); | 106 | int handle = core_alloc_maximum(sizep, &buflib_ops_locked); |
107 | if(handle < 0) { | 107 | if(handle < 0) { |
108 | splashf(5*HZ, "Out of memory"); | 108 | splashf(5*HZ, "Out of memory"); |
109 | return -2; | 109 | return -2; |
diff --git a/firmware/buflib.c b/firmware/buflib.c index ea57dbb379..8fc32f7406 100644 --- a/firmware/buflib.c +++ b/firmware/buflib.c | |||
@@ -633,7 +633,7 @@ buflib_buffer_in(struct buflib_context *ctx, int size) | |||
633 | int | 633 | int |
634 | buflib_alloc(struct buflib_context *ctx, size_t size) | 634 | buflib_alloc(struct buflib_context *ctx, size_t size) |
635 | { | 635 | { |
636 | return buflib_alloc_ex(ctx, size, NULL, NULL); | 636 | return buflib_alloc_ex(ctx, size, NULL); |
637 | } | 637 | } |
638 | 638 | ||
639 | /* Allocate a buffer of size bytes, returning a handle for it. | 639 | /* Allocate a buffer of size bytes, returning a handle for it. |
@@ -647,11 +647,9 @@ buflib_alloc(struct buflib_context *ctx, size_t size) | |||
647 | */ | 647 | */ |
648 | 648 | ||
649 | int | 649 | int |
650 | buflib_alloc_ex(struct buflib_context *ctx, size_t size, const char *name, | 650 | buflib_alloc_ex(struct buflib_context *ctx, size_t size, |
651 | struct buflib_callbacks *ops) | 651 | struct buflib_callbacks *ops) |
652 | { | 652 | { |
653 | (void)name; | ||
654 | |||
655 | union buflib_data *handle, *block; | 653 | union buflib_data *handle, *block; |
656 | bool last; | 654 | bool last; |
657 | /* This really is assigned a value before use */ | 655 | /* This really is assigned a value before use */ |
@@ -943,7 +941,7 @@ buflib_available(struct buflib_context* ctx) | |||
943 | * serviced anyway). | 941 | * serviced anyway). |
944 | */ | 942 | */ |
945 | int | 943 | int |
946 | buflib_alloc_maximum(struct buflib_context* ctx, const char* name, size_t *size, struct buflib_callbacks *ops) | 944 | buflib_alloc_maximum(struct buflib_context* ctx, size_t *size, struct buflib_callbacks *ops) |
947 | { | 945 | { |
948 | /* ignore ctx->compact because it's true if all movable blocks are contiguous | 946 | /* ignore ctx->compact because it's true if all movable blocks are contiguous |
949 | * even if the buffer has holes due to unmovable allocations */ | 947 | * even if the buffer has holes due to unmovable allocations */ |
@@ -960,7 +958,7 @@ buflib_alloc_maximum(struct buflib_context* ctx, const char* name, size_t *size, | |||
960 | if (*size <= 0) /* OOM */ | 958 | if (*size <= 0) /* OOM */ |
961 | return -1; | 959 | return -1; |
962 | 960 | ||
963 | return buflib_alloc_ex(ctx, *size, name, ops); | 961 | return buflib_alloc_ex(ctx, *size, ops); |
964 | } | 962 | } |
965 | 963 | ||
966 | /* Shrink the allocation indicated by the handle according to new_start and | 964 | /* Shrink the allocation indicated by the handle according to new_start and |
@@ -1073,13 +1071,6 @@ unsigned buflib_pin_count(struct buflib_context *ctx, int handle) | |||
1073 | return data[-bidx_PIN].pincount; | 1071 | return data[-bidx_PIN].pincount; |
1074 | } | 1072 | } |
1075 | 1073 | ||
1076 | const char* buflib_get_name(struct buflib_context *ctx, int handle) | ||
1077 | { | ||
1078 | (void)ctx; | ||
1079 | (void)handle; | ||
1080 | return ""; | ||
1081 | } | ||
1082 | |||
1083 | #ifdef DEBUG | 1074 | #ifdef DEBUG |
1084 | 1075 | ||
1085 | void *buflib_get_data(struct buflib_context *ctx, int handle) | 1076 | void *buflib_get_data(struct buflib_context *ctx, int handle) |
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c index 5902f8b3fd..41564194d0 100644 --- a/firmware/common/dircache.c +++ b/firmware/common/dircache.c | |||
@@ -479,7 +479,7 @@ static void binding_dissolve_volume(struct dircache_runinfo_volume *dcrivolp) | |||
479 | static int alloc_cache(size_t size) | 479 | static int alloc_cache(size_t size) |
480 | { | 480 | { |
481 | /* pad with one extra-- see alloc_name() and free_name() */ | 481 | /* pad with one extra-- see alloc_name() and free_name() */ |
482 | return core_alloc_ex("dircache", size + 1, &dircache_runinfo.ops); | 482 | return core_alloc_ex(size + 1, &dircache_runinfo.ops); |
483 | } | 483 | } |
484 | 484 | ||
485 | /** | 485 | /** |
diff --git a/firmware/common/unicode.c b/firmware/common/unicode.c index e53ad6bcb0..1ed2e5e49d 100644 --- a/firmware/common/unicode.c +++ b/firmware/common/unicode.c | |||
@@ -166,15 +166,15 @@ static unsigned short default_cp_table_buf[MAX_CP_TABLE_SIZE+1]; | |||
166 | default_cp_table_buf | 166 | default_cp_table_buf |
167 | #define cp_table_free(handle) \ | 167 | #define cp_table_free(handle) \ |
168 | do {} while (0) | 168 | do {} while (0) |
169 | #define cp_table_alloc(filename, size, opsp) \ | 169 | #define cp_table_alloc(size, opsp) \ |
170 | ({ (void)(opsp); 1; }) | 170 | ({ (void)(opsp); 1; }) |
171 | #define cp_table_pin(handle) \ | 171 | #define cp_table_pin(handle) \ |
172 | do { (void)handle; } while(0) | 172 | do { (void)handle; } while(0) |
173 | #define cp_table_unpin(handle) \ | 173 | #define cp_table_unpin(handle) \ |
174 | do { (void)handle; } while(0) | 174 | do { (void)handle; } while(0) |
175 | #else | 175 | #else |
176 | #define cp_table_alloc(filename, size, opsp) \ | 176 | #define cp_table_alloc(size, opsp) \ |
177 | core_alloc_ex((filename), (size), (opsp)) | 177 | core_alloc_ex((size), (opsp)) |
178 | #define cp_table_free(handle) \ | 178 | #define cp_table_free(handle) \ |
179 | core_free(handle) | 179 | core_free(handle) |
180 | #define cp_table_get_data(handle) \ | 180 | #define cp_table_get_data(handle) \ |
@@ -223,7 +223,7 @@ static int alloc_and_load_cp_table(int cp, void *buf) | |||
223 | !(size % (off_t)sizeof (uint16_t))) { | 223 | !(size % (off_t)sizeof (uint16_t))) { |
224 | 224 | ||
225 | /* if the buffer is provided, use that but don't alloc */ | 225 | /* if the buffer is provided, use that but don't alloc */ |
226 | int handle = buf ? 0 : cp_table_alloc(filename, size, NULL); | 226 | int handle = buf ? 0 : cp_table_alloc(size, NULL); |
227 | if (handle > 0) { | 227 | if (handle > 0) { |
228 | cp_table_pin(handle); | 228 | cp_table_pin(handle); |
229 | buf = cp_table_get_data(handle); | 229 | buf = cp_table_get_data(handle); |
diff --git a/firmware/common/zip.c b/firmware/common/zip.c index 6d250abb58..2d560e472e 100644 --- a/firmware/common/zip.c +++ b/firmware/common/zip.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include "crc32.h" | 31 | #include "crc32.h" |
32 | #include "rbendian.h" | 32 | #include "rbendian.h" |
33 | 33 | ||
34 | #define zip_core_alloc(N) core_alloc_ex("zip",(N),&buflib_ops_locked) | 34 | #define zip_core_alloc(N) core_alloc_ex((N),&buflib_ops_locked) |
35 | 35 | ||
36 | enum { | 36 | enum { |
37 | ZIP_SIG_ED = 0x06054b50, | 37 | ZIP_SIG_ED = 0x06054b50, |
diff --git a/firmware/core_alloc.c b/firmware/core_alloc.c index 0374c801c1..f5cc7f3189 100644 --- a/firmware/core_alloc.c +++ b/firmware/core_alloc.c | |||
@@ -51,7 +51,7 @@ void core_allocator_init(void) | |||
51 | 51 | ||
52 | buflib_init(&core_ctx, start, audiobufend - start); | 52 | buflib_init(&core_ctx, start, audiobufend - start); |
53 | 53 | ||
54 | test_alloc = core_alloc("test", 112); | 54 | test_alloc = core_alloc(112); |
55 | } | 55 | } |
56 | 56 | ||
57 | bool core_test_free(void) | 57 | bool core_test_free(void) |
@@ -69,14 +69,14 @@ bool core_test_free(void) | |||
69 | * Note: Buffers allocated by this functions are movable. | 69 | * Note: Buffers allocated by this functions are movable. |
70 | * Don't pass them to functions that call yield() | 70 | * Don't pass them to functions that call yield() |
71 | * like disc input/output. */ | 71 | * like disc input/output. */ |
72 | int core_alloc(const char* name, size_t size) | 72 | int core_alloc(size_t size) |
73 | { | 73 | { |
74 | return buflib_alloc_ex(&core_ctx, size, name, NULL); | 74 | return buflib_alloc_ex(&core_ctx, size, NULL); |
75 | } | 75 | } |
76 | 76 | ||
77 | int core_alloc_ex(const char* name, size_t size, struct buflib_callbacks *ops) | 77 | int core_alloc_ex(size_t size, struct buflib_callbacks *ops) |
78 | { | 78 | { |
79 | return buflib_alloc_ex(&core_ctx, size, name, ops); | 79 | return buflib_alloc_ex(&core_ctx, size, ops); |
80 | } | 80 | } |
81 | 81 | ||
82 | size_t core_available(void) | 82 | size_t core_available(void) |
@@ -94,9 +94,9 @@ int core_free(int handle) | |||
94 | return buflib_free(&core_ctx, handle); | 94 | return buflib_free(&core_ctx, handle); |
95 | } | 95 | } |
96 | 96 | ||
97 | int core_alloc_maximum(const char* name, size_t *size, struct buflib_callbacks *ops) | 97 | int core_alloc_maximum(size_t *size, struct buflib_callbacks *ops) |
98 | { | 98 | { |
99 | return buflib_alloc_maximum(&core_ctx, name, size, ops); | 99 | return buflib_alloc_maximum(&core_ctx, size, ops); |
100 | } | 100 | } |
101 | 101 | ||
102 | bool core_shrink(int handle, void* new_start, size_t new_size) | 102 | bool core_shrink(int handle, void* new_start, size_t new_size) |
@@ -119,12 +119,6 @@ unsigned core_pin_count(int handle) | |||
119 | return buflib_pin_count(&core_ctx, handle); | 119 | return buflib_pin_count(&core_ctx, handle); |
120 | } | 120 | } |
121 | 121 | ||
122 | const char* core_get_name(int handle) | ||
123 | { | ||
124 | const char *name = buflib_get_name(&core_ctx, handle); | ||
125 | return name ?: "<anonymous>"; | ||
126 | } | ||
127 | |||
128 | int core_get_num_blocks(void) | 122 | int core_get_num_blocks(void) |
129 | { | 123 | { |
130 | return buflib_get_num_blocks(&core_ctx); | 124 | return buflib_get_num_blocks(&core_ctx); |
diff --git a/firmware/font.c b/firmware/font.c index 8f0808ba87..2a2975cbf2 100644 --- a/firmware/font.c +++ b/firmware/font.c | |||
@@ -525,7 +525,7 @@ int font_load_ex( const char *path, size_t buf_size, int glyphs ) | |||
525 | font_id = open_slot; | 525 | font_id = open_slot; |
526 | 526 | ||
527 | /* allocate mem */ | 527 | /* allocate mem */ |
528 | int handle = core_alloc_ex( NULL, | 528 | int handle = core_alloc_ex( |
529 | bufsize + sizeof( struct buflib_alloc_data ), | 529 | bufsize + sizeof( struct buflib_alloc_data ), |
530 | &buflibops ); | 530 | &buflibops ); |
531 | if ( handle <= 0 ) | 531 | if ( handle <= 0 ) |
diff --git a/firmware/include/buflib.h b/firmware/include/buflib.h index d2231ab79d..e54ec72a99 100644 --- a/firmware/include/buflib.h +++ b/firmware/include/buflib.h | |||
@@ -62,8 +62,7 @@ struct buflib_context | |||
62 | * to the actually requested number of bytes. | 62 | * to the actually requested number of bytes. |
63 | * | 63 | * |
64 | * The total number of bytes consumed by an allocation is | 64 | * The total number of bytes consumed by an allocation is |
65 | * BUFLIB_ALLOC_OVERHEAD + requested bytes + strlen(<name passed to | 65 | * BUFLIB_ALLOC_OVERHEAD + requested bytes + pad to pointer size |
66 | * buflib_alloc_ex()) + pad to pointer size | ||
67 | */ | 66 | */ |
68 | #define BUFLIB_ALLOC_OVERHEAD (5*sizeof(union buflib_data)) | 67 | #define BUFLIB_ALLOC_OVERHEAD (5*sizeof(union buflib_data)) |
69 | 68 | ||
@@ -215,7 +214,6 @@ int buflib_alloc(struct buflib_context *context, size_t size); | |||
215 | * Allocates memory from the buflib's memory pool with additional callbacks | 214 | * Allocates memory from the buflib's memory pool with additional callbacks |
216 | * and flags | 215 | * and flags |
217 | * | 216 | * |
218 | * name: A string identifier giving this allocation a name | ||
219 | * size: How many bytes to allocate | 217 | * size: How many bytes to allocate |
220 | * ops: a struct with pointers to callback functions (see above). | 218 | * ops: a struct with pointers to callback functions (see above). |
221 | * if "ops" is NULL: Buffer is movable. | 219 | * if "ops" is NULL: Buffer is movable. |
@@ -223,7 +221,7 @@ int buflib_alloc(struct buflib_context *context, size_t size); | |||
223 | * Returns: A positive integer handle identifying this allocation, or | 221 | * Returns: A positive integer handle identifying this allocation, or |
224 | * a negative value on error (0 is also not a valid handle) | 222 | * a negative value on error (0 is also not a valid handle) |
225 | */ | 223 | */ |
226 | int buflib_alloc_ex(struct buflib_context *ctx, size_t size, const char *name, | 224 | int buflib_alloc_ex(struct buflib_context *ctx, size_t size, |
227 | struct buflib_callbacks *ops); | 225 | struct buflib_callbacks *ops); |
228 | 226 | ||
229 | 227 | ||
@@ -241,15 +239,14 @@ int buflib_alloc_ex(struct buflib_context *ctx, size_t size, const char *name, | |||
241 | * and even shrinks other allocations. However, do not depend on this behavior, | 239 | * and even shrinks other allocations. However, do not depend on this behavior, |
242 | * it may change. | 240 | * it may change. |
243 | * | 241 | * |
244 | * name: A string identifier giving this allocation a name | ||
245 | * size: The actual size will be returned into size | 242 | * size: The actual size will be returned into size |
246 | * ops: a struct with pointers to callback functions | 243 | * ops: a struct with pointers to callback functions |
247 | * | 244 | * |
248 | * Returns: A positive integer handle identifying this allocation, or | 245 | * Returns: A positive integer handle identifying this allocation, or |
249 | * a negative value on error (0 is also not a valid handle) | 246 | * a negative value on error (0 is also not a valid handle) |
250 | */ | 247 | */ |
251 | int buflib_alloc_maximum(struct buflib_context* ctx, const char* name, | 248 | int buflib_alloc_maximum(struct buflib_context* ctx, |
252 | size_t *size, struct buflib_callbacks *ops); | 249 | size_t *size, struct buflib_callbacks *ops); |
253 | 250 | ||
254 | /** | 251 | /** |
255 | * Queries the data pointer for the given handle. It's actually a cheap | 252 | * Queries the data pointer for the given handle. It's actually a cheap |
@@ -349,18 +346,6 @@ void buflib_buffer_in(struct buflib_context *ctx, int size); | |||
349 | /* debugging */ | 346 | /* debugging */ |
350 | 347 | ||
351 | /** | 348 | /** |
352 | * Returns the name, as given to buflib_alloc() and buflib_allloc_ex(), of the | ||
353 | * allocation associated with the given handle. As naming allocations | ||
354 | * is optional, there might be no name associated. | ||
355 | * | ||
356 | * handle: The handle indicating the allocation | ||
357 | * | ||
358 | * Returns: A pointer to the string identifier of the allocation, or NULL | ||
359 | * if none was specified with buflib_alloc_ex(). | ||
360 | */ | ||
361 | const char* buflib_get_name(struct buflib_context *ctx, int handle); | ||
362 | |||
363 | /** | ||
364 | * Gets the number of blocks in the entire buffer, allocated or unallocated | 349 | * Gets the number of blocks in the entire buffer, allocated or unallocated |
365 | * | 350 | * |
366 | * Only available if BUFLIB_DEBUG_BLOCK_SIGNLE is defined | 351 | * Only available if BUFLIB_DEBUG_BLOCK_SIGNLE is defined |
diff --git a/firmware/include/core_alloc.h b/firmware/include/core_alloc.h index 13d8165be2..8011c227b1 100644 --- a/firmware/include/core_alloc.h +++ b/firmware/include/core_alloc.h | |||
@@ -11,9 +11,9 @@ | |||
11 | * they have a predefined context | 11 | * they have a predefined context |
12 | */ | 12 | */ |
13 | void core_allocator_init(void) INIT_ATTR; | 13 | void core_allocator_init(void) INIT_ATTR; |
14 | int core_alloc(const char* name, size_t size); | 14 | int core_alloc(size_t size); |
15 | int core_alloc_ex(const char* name, size_t size, struct buflib_callbacks *ops); | 15 | int core_alloc_ex(size_t size, struct buflib_callbacks *ops); |
16 | int core_alloc_maximum(const char* name, size_t *size, struct buflib_callbacks *ops); | 16 | int core_alloc_maximum(size_t *size, struct buflib_callbacks *ops); |
17 | bool core_shrink(int handle, void* new_start, size_t new_size); | 17 | bool core_shrink(int handle, void* new_start, size_t new_size); |
18 | void core_pin(int handle); | 18 | void core_pin(int handle); |
19 | void core_unpin(int handle); | 19 | void core_unpin(int handle); |
@@ -21,7 +21,6 @@ unsigned core_pin_count(int handle); | |||
21 | int core_free(int handle); | 21 | int core_free(int handle); |
22 | size_t core_available(void); | 22 | size_t core_available(void); |
23 | size_t core_allocatable(void); | 23 | size_t core_allocatable(void); |
24 | const char* core_get_name(int handle); | ||
25 | #ifdef DEBUG | 24 | #ifdef DEBUG |
26 | void core_check_valid(void); | 25 | void core_check_valid(void); |
27 | #endif | 26 | #endif |
diff --git a/firmware/linuxboot.c b/firmware/linuxboot.c index 419044b5a9..74d87fbd64 100644 --- a/firmware/linuxboot.c +++ b/firmware/linuxboot.c | |||
@@ -80,7 +80,7 @@ static int uimage_alloc_state(const struct uimage_header* uh) | |||
80 | #ifdef HAVE_UIMAGE_COMP_GZIP | 80 | #ifdef HAVE_UIMAGE_COMP_GZIP |
81 | case IH_COMP_GZIP: | 81 | case IH_COMP_GZIP: |
82 | size = inflate_size + inflate_align - 1; | 82 | size = inflate_size + inflate_align - 1; |
83 | return core_alloc_ex("inflate", size, &buflib_ops_locked); | 83 | return core_alloc_ex(size, &buflib_ops_locked); |
84 | #endif | 84 | #endif |
85 | 85 | ||
86 | default: | 86 | default: |
@@ -206,7 +206,7 @@ int uimage_load(struct uimage_header* uh, size_t* out_size, | |||
206 | return E_OUT_OF_MEMORY; | 206 | return E_OUT_OF_MEMORY; |
207 | 207 | ||
208 | *out_size = 0; | 208 | *out_size = 0; |
209 | int out_h = core_alloc_maximum("uimage", out_size, &buflib_ops_locked); | 209 | int out_h = core_alloc_maximum(out_size, &buflib_ops_locked); |
210 | if(out_h <= 0) { | 210 | if(out_h <= 0) { |
211 | ret = E_OUT_OF_MEMORY; | 211 | ret = E_OUT_OF_MEMORY; |
212 | goto err; | 212 | goto err; |
diff --git a/firmware/rolo.c b/firmware/rolo.c index d280e39243..a3e6d5c2b9 100644 --- a/firmware/rolo.c +++ b/firmware/rolo.c | |||
@@ -239,7 +239,7 @@ int rolo_load(const char* filename) | |||
239 | 239 | ||
240 | /* get the system buffer. release only in case of error, otherwise | 240 | /* get the system buffer. release only in case of error, otherwise |
241 | * we don't return anyway */ | 241 | * we don't return anyway */ |
242 | rolo_handle = core_alloc_maximum("rolo", &filebuf_size, &buflib_ops_locked); | 242 | rolo_handle = core_alloc_maximum(&filebuf_size, &buflib_ops_locked); |
243 | if (rolo_handle < 0) | 243 | if (rolo_handle < 0) |
244 | { | 244 | { |
245 | rolo_error("OOM"); | 245 | rolo_error("OOM"); |
diff --git a/firmware/target/arm/ata-nand-telechips.c b/firmware/target/arm/ata-nand-telechips.c index 55f6b1f3f7..d61c223219 100644 --- a/firmware/target/arm/ata-nand-telechips.c +++ b/firmware/target/arm/ata-nand-telechips.c | |||
@@ -915,7 +915,7 @@ int nand_init(void) | |||
915 | #ifndef BOOTLOADER | 915 | #ifndef BOOTLOADER |
916 | /* Use chip info to allocate the correct size LPT buffer */ | 916 | /* Use chip info to allocate the correct size LPT buffer */ |
917 | lptbuf_size = sizeof(struct lpt_entry) * segments_per_bank * total_banks; | 917 | lptbuf_size = sizeof(struct lpt_entry) * segments_per_bank * total_banks; |
918 | lpt_handle = core_alloc("lpt lookup", lptbuf_size); | 918 | lpt_handle = core_alloc(lptbuf_size); |
919 | struct lpt_entry* lpt_lookup = core_get_data(lpt_handle); | 919 | struct lpt_entry* lpt_lookup = core_get_data(lpt_handle); |
920 | #else | 920 | #else |
921 | /* Use a static array in the bootloader */ | 921 | /* Use a static array in the bootloader */ |
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c index f13904628d..a1985472a0 100644 --- a/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c +++ b/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c | |||
@@ -303,7 +303,7 @@ static void cfs_init(void) | |||
303 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inodes_nr[1]), 1, §or); | 303 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inodes_nr[1]), 1, §or); |
304 | inode = (struct cfs_inode*)§or; | 304 | inode = (struct cfs_inode*)§or; |
305 | #ifndef BOOTLOADER | 305 | #ifndef BOOTLOADER |
306 | sectors_handle = core_alloc("ata sectors", VFAT_SECTOR_SIZE(inode->filesize)); | 306 | sectors_handle = core_alloc(VFAT_SECTOR_SIZE(inode->filesize)); |
307 | unsigned long *sectors = core_get_data(sectors_handle); | 307 | unsigned long *sectors = core_get_data(sectors_handle); |
308 | #else | 308 | #else |
309 | static unsigned long _sector[VFAT_SECTOR_SIZE(1024*1024*1024)]; /* 1GB guess */ | 309 | static unsigned long _sector[VFAT_SECTOR_SIZE(1024*1024*1024)]; /* 1GB guess */ |
diff --git a/firmware/target/mips/ingenic_x1000/installer-x1000.c b/firmware/target/mips/ingenic_x1000/installer-x1000.c index acc1d7b711..d2f9e4e5e0 100644 --- a/firmware/target/mips/ingenic_x1000/installer-x1000.c +++ b/firmware/target/mips/ingenic_x1000/installer-x1000.c | |||
@@ -151,7 +151,7 @@ static int updater_init(struct updater* u) | |||
151 | 151 | ||
152 | /* buf_len is a bit oversized here, but it's not really important */ | 152 | /* buf_len is a bit oversized here, but it's not really important */ |
153 | u->buf_len = u->img_len + sizeof(mtar_t) + 2*CACHEALIGN_SIZE; | 153 | u->buf_len = u->img_len + sizeof(mtar_t) + 2*CACHEALIGN_SIZE; |
154 | u->buf_hnd = core_alloc_ex("boot_image", u->buf_len, &buflib_ops_locked); | 154 | u->buf_hnd = core_alloc_ex(u->buf_len, &buflib_ops_locked); |
155 | if(u->buf_hnd < 0) { | 155 | if(u->buf_hnd < 0) { |
156 | rc = IERR_OUT_OF_MEMORY; | 156 | rc = IERR_OUT_OF_MEMORY; |
157 | goto error; | 157 | goto error; |
diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c index 08b1f0b7e7..714af9d535 100644 --- a/firmware/usbstack/usb_storage.c +++ b/firmware/usbstack/usb_storage.c | |||
@@ -451,8 +451,7 @@ void usb_storage_init_connection(void) | |||
451 | unsigned char * buffer; | 451 | unsigned char * buffer; |
452 | 452 | ||
453 | // Add 31 to handle worst-case misalignment | 453 | // Add 31 to handle worst-case misalignment |
454 | usb_handle = core_alloc_ex("usb storage", | 454 | usb_handle = core_alloc_ex(ALLOCATE_BUFFER_SIZE + MAX_CBW_SIZE + 31, |
455 | ALLOCATE_BUFFER_SIZE + MAX_CBW_SIZE + 31, | ||
456 | &buflib_ops_locked); | 455 | &buflib_ops_locked); |
457 | if (usb_handle < 0) | 456 | if (usb_handle < 0) |
458 | panicf("%s(): OOM", __func__); | 457 | panicf("%s(): OOM", __func__); |
diff --git a/lib/rbcodec/dsp/pbe.c b/lib/rbcodec/dsp/pbe.c index 634849d91c..ca4e30ba0f 100644 --- a/lib/rbcodec/dsp/pbe.c +++ b/lib/rbcodec/dsp/pbe.c | |||
@@ -49,7 +49,7 @@ static int handle = -1; | |||
49 | 49 | ||
50 | static int pbe_buffer_alloc(void) | 50 | static int pbe_buffer_alloc(void) |
51 | { | 51 | { |
52 | handle = core_alloc("dsp_pbe_buffer", PBE_BUFSIZE); | 52 | handle = core_alloc(PBE_BUFSIZE); |
53 | return handle; | 53 | return handle; |
54 | } | 54 | } |
55 | 55 | ||
diff --git a/lib/rbcodec/dsp/surround.c b/lib/rbcodec/dsp/surround.c index 9a1f7be8b6..c0dce33a47 100644 --- a/lib/rbcodec/dsp/surround.c +++ b/lib/rbcodec/dsp/surround.c | |||
@@ -66,7 +66,7 @@ static int handle = -1; | |||
66 | 66 | ||
67 | static int surround_buffer_alloc(void) | 67 | static int surround_buffer_alloc(void) |
68 | { | 68 | { |
69 | handle = core_alloc("dsp_surround_buffer", SURROUND_BUFSIZE); | 69 | handle = core_alloc(SURROUND_BUFSIZE); |
70 | return handle; | 70 | return handle; |
71 | } | 71 | } |
72 | 72 | ||