From 42df7aa04a65314e1ae943ecd5c5beea32cda031 Mon Sep 17 00:00:00 2001 From: Sergey Gavrilov Date: Thu, 20 Oct 2022 20:58:11 +1000 Subject: [PATCH] Fix FuriString oplist (init move) (#1894) * FuriString, Infrared: fix oplist and drop string_t. * Elf loader: log size * Comment fix * API: furi_hal_console_init --- applications/main/infrared/infrared_cli.c | 15 +++++------ firmware/targets/f7/api_symbols.csv | 4 +-- furi/core/string.h | 31 +++++++++++++---------- lib/flipper_application/elf/elf_file.c | 10 ++++++++ 4 files changed, 37 insertions(+), 23 deletions(-) diff --git a/applications/main/infrared/infrared_cli.c b/applications/main/infrared/infrared_cli.c index 7723dc97..5a04f749 100644 --- a/applications/main/infrared/infrared_cli.c +++ b/applications/main/infrared/infrared_cli.c @@ -9,12 +9,11 @@ #include "infrared_signal.h" #include "infrared_brute_force.h" -#include "m-dict.h" -#include "m-string.h" +#include #define INFRARED_CLI_BUF_SIZE 10 -DICT_DEF2(dict_signals, string_t, STRING_OPLIST, int, M_DEFAULT_OPLIST) +DICT_DEF2(dict_signals, FuriString*, FURI_STRING_OPLIST, int, M_DEFAULT_OPLIST) enum RemoteTypes { TV = 0, AC = 1 }; @@ -416,7 +415,7 @@ static void infrared_cli_list_remote_signals(enum RemoteTypes remote_type) { Storage* storage = furi_record_open(RECORD_STORAGE); FlipperFormat* ff = flipper_format_buffered_file_alloc(storage); dict_signals_t signals_dict; - string_t key; + FuriString* key; const char* remote_file = NULL; bool success = false; int max = 1; @@ -433,7 +432,7 @@ static void infrared_cli_list_remote_signals(enum RemoteTypes remote_type) { } dict_signals_init(signals_dict); - string_init(key); + key = furi_string_alloc(); success = flipper_format_buffered_file_open_existing(ff, remote_file); if(success) { @@ -441,7 +440,7 @@ static void infrared_cli_list_remote_signals(enum RemoteTypes remote_type) { signal_name = furi_string_alloc(); printf("Valid signals:\r\n"); while(flipper_format_read_string(ff, "name", signal_name)) { - string_set_str(key, furi_string_get_cstr(signal_name)); + furi_string_set_str(key, furi_string_get_cstr(signal_name)); int* v = dict_signals_get(signals_dict, key); if(v != NULL) { (*v)++; @@ -453,12 +452,12 @@ static void infrared_cli_list_remote_signals(enum RemoteTypes remote_type) { dict_signals_it_t it; for(dict_signals_it(it, signals_dict); !dict_signals_end_p(it); dict_signals_next(it)) { const struct dict_signals_pair_s* pair = dict_signals_cref(it); - printf("\t%s\r\n", string_get_cstr(pair->key)); + printf("\t%s\r\n", furi_string_get_cstr(pair->key)); } furi_string_free(signal_name); } - string_clear(key); + furi_string_free(key); dict_signals_clear(signals_dict); flipper_format_free(ff); furi_record_close(RECORD_STORAGE); diff --git a/firmware/targets/f7/api_symbols.csv b/firmware/targets/f7/api_symbols.csv index b65de9a9..6aa8591e 100644 --- a/firmware/targets/f7/api_symbols.csv +++ b/firmware/targets/f7/api_symbols.csv @@ -1,5 +1,5 @@ entry,status,name,type,params -Version,+,3.3,, +Version,+,3.4,, Header,+,applications/services/bt/bt_service/bt.h,, Header,+,applications/services/cli/cli.h,, Header,+,applications/services/cli/cli_vcp.h,, @@ -976,7 +976,7 @@ Function,-,furi_hal_compress_icon_decode,void,"const uint8_t*, uint8_t**" Function,-,furi_hal_compress_icon_init,void, Function,+,furi_hal_console_disable,void, Function,+,furi_hal_console_enable,void, -Function,-,furi_hal_console_init,void, +Function,+,furi_hal_console_init,void, Function,+,furi_hal_console_printf,void,"const char[], ..." Function,+,furi_hal_console_puts,void,const char* Function,+,furi_hal_console_set_tx_callback,void,"FuriHalConsoleTxCallback, void*" diff --git a/furi/core/string.h b/furi/core/string.h index 01b26cce..0523d3ba 100644 --- a/furi/core/string.h +++ b/furi/core/string.h @@ -718,22 +718,27 @@ void furi_string_utf8_decode(char c, FuriStringUTF8State* state, FuriStringUnico */ #define F_STR_INIT_SET(a, b) ((a) = furi_string_alloc_set(b)) +/** + * @brief INIT MOVE OPLIST for FuriString. + */ +#define F_STR_INIT_MOVE(a, b) ((a) = furi_string_alloc_move(b)) + /** * @brief OPLIST for FuriString. */ -#define FURI_STRING_OPLIST \ - (INIT(F_STR_INIT), \ - INIT_SET(F_STR_INIT_SET), \ - SET(furi_string_set), \ - INIT_MOVE(furi_string_alloc_move), \ - MOVE(furi_string_move), \ - SWAP(furi_string_swap), \ - RESET(furi_string_reset), \ - EMPTY_P(furi_string_empty), \ - CLEAR(furi_string_free), \ - HASH(furi_string_hash), \ - EQUAL(furi_string_equal), \ - CMP(furi_string_cmp), \ +#define FURI_STRING_OPLIST \ + (INIT(F_STR_INIT), \ + INIT_SET(F_STR_INIT_SET), \ + SET(furi_string_set), \ + INIT_MOVE(F_STR_INIT_MOVE), \ + MOVE(furi_string_move), \ + SWAP(furi_string_swap), \ + RESET(furi_string_reset), \ + EMPTY_P(furi_string_empty), \ + CLEAR(furi_string_free), \ + HASH(furi_string_hash), \ + EQUAL(furi_string_equal), \ + CMP(furi_string_cmp), \ TYPE(FuriString*)) #ifdef __cplusplus diff --git a/lib/flipper_application/elf/elf_file.c b/lib/flipper_application/elf/elf_file.c index 3fe57162..2082e550 100644 --- a/lib/flipper_application/elf/elf_file.c +++ b/lib/flipper_application/elf/elf_file.c @@ -786,6 +786,16 @@ ELFFileLoadStatus elf_file_load_sections(ELFFile* elf) { FURI_LOG_D(TAG, "Trampoline cache size: %u", AddressCache_size(elf->trampoline_cache)); AddressCache_clear(elf->relocation_cache); + { + size_t total_size = 0; + for(ELFSectionDict_it(it, elf->sections); !ELFSectionDict_end_p(it); + ELFSectionDict_next(it)) { + ELFSectionDict_itref_t* itref = ELFSectionDict_ref(it); + total_size += itref->value.size; + } + FURI_LOG_I(TAG, "Total size of loaded sections: %u", total_size); + } + return status; }