SubGHz combine FuriString allocs

This commit is contained in:
MX 2023-05-05 03:51:16 +03:00
parent 4e78367ec4
commit b0b9e507e7
No known key found for this signature in database
GPG key ID: 7CCC66B7DBDD1C83
13 changed files with 59 additions and 120 deletions

View file

@ -24,14 +24,10 @@
static void subghz_scene_receiver_update_statusbar(void* context) {
SubGhz* subghz = context;
FuriString* history_stat_str;
history_stat_str = furi_string_alloc();
FuriString* history_stat_str = furi_string_alloc();
if(!subghz_history_get_text_space_left(subghz->txrx->history, history_stat_str)) {
FuriString* frequency_str;
FuriString* modulation_str;
frequency_str = furi_string_alloc();
modulation_str = furi_string_alloc();
FuriString* frequency_str = furi_string_alloc();
FuriString* modulation_str = furi_string_alloc();
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
@ -62,11 +58,9 @@ static void subghz_scene_add_to_history_callback(
void* context) {
furi_assert(context);
SubGhz* subghz = context;
FuriString* item_name;
FuriString* item_time;
FuriString* item_name = furi_string_alloc();
FuriString* item_time = furi_string_alloc();
uint16_t idx = subghz_history_get_item(subghz->txrx->history);
item_name = furi_string_alloc();
item_time = furi_string_alloc();
if(subghz_history_add_to_history(subghz->txrx->history, decoder_base, subghz->txrx->preset)) {
furi_string_reset(item_name);
@ -90,8 +84,7 @@ static void subghz_scene_add_to_history_callback(
}
bool subghz_scene_decode_raw_start(SubGhz* subghz) {
FuriString* file_name;
file_name = furi_string_alloc();
FuriString* file_name = furi_string_alloc();
bool success = false;
do {
if(!flipper_format_rewind(subghz->txrx->fff_data)) {
@ -148,8 +141,7 @@ bool subghz_scene_decode_raw_next(SubGhz* subghz) {
}
// Update progress info
FuriString* progress_str;
progress_str = furi_string_alloc();
FuriString* progress_str = furi_string_alloc();
subghz_file_encoder_worker_get_text_progress(
subghz->decode_raw_file_worker_encoder, progress_str);
@ -164,10 +156,8 @@ bool subghz_scene_decode_raw_next(SubGhz* subghz) {
void subghz_scene_decode_raw_on_enter(void* context) {
SubGhz* subghz = context;
FuriString* item_name;
FuriString* item_time;
item_name = furi_string_alloc();
item_time = furi_string_alloc();
FuriString* item_name = furi_string_alloc();
FuriString* item_time = furi_string_alloc();
subghz_view_receiver_set_lock(subghz->subghz_receiver, subghz->lock);
subghz_view_receiver_set_mode(subghz->subghz_receiver, SubGhzViewReceiverModeFile);

View file

@ -11,13 +11,9 @@ void subghz_scene_delete_callback(GuiButtonType result, InputType type, void* co
void subghz_scene_delete_on_enter(void* context) {
SubGhz* subghz = context;
FuriString* frequency_str;
FuriString* modulation_str;
FuriString* text;
frequency_str = furi_string_alloc();
modulation_str = furi_string_alloc();
text = furi_string_alloc();
FuriString* frequency_str = furi_string_alloc();
FuriString* modulation_str = furi_string_alloc();
FuriString* text = furi_string_alloc();
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
widget_add_string_element(

View file

@ -15,11 +15,8 @@ void subghz_scene_delete_raw_callback(GuiButtonType result, InputType type, void
void subghz_scene_delete_raw_on_enter(void* context) {
SubGhz* subghz = context;
FuriString* frequency_str;
FuriString* modulation_str;
frequency_str = furi_string_alloc();
modulation_str = furi_string_alloc();
FuriString* frequency_str = furi_string_alloc();
FuriString* modulation_str = furi_string_alloc();
char delete_str[SUBGHZ_MAX_LEN_NAME + 16];
FuriString* file_name;

View file

@ -12,8 +12,7 @@
bool subghz_scene_read_raw_update_filename(SubGhz* subghz) {
bool ret = false;
//set the path to read the file
FuriString* temp_str;
temp_str = furi_string_alloc();
FuriString* temp_str = furi_string_alloc();
do {
if(!flipper_format_rewind(subghz->txrx->fff_data)) {
FURI_LOG_E(TAG, "Rewind error");
@ -38,11 +37,8 @@ static void subghz_scene_read_raw_update_statusbar(void* context) {
furi_assert(context);
SubGhz* subghz = context;
FuriString* frequency_str;
FuriString* modulation_str;
frequency_str = furi_string_alloc();
modulation_str = furi_string_alloc();
FuriString* frequency_str = furi_string_alloc();
FuriString* modulation_str = furi_string_alloc();
#ifdef SUBGHZ_EXT_PRESET_NAME
subghz_get_frequency_modulation(subghz, frequency_str, NULL);
@ -74,8 +70,7 @@ void subghz_scene_read_raw_callback_end_tx(void* context) {
void subghz_scene_read_raw_on_enter(void* context) {
SubGhz* subghz = context;
FuriString* file_name;
file_name = furi_string_alloc();
FuriString* file_name = furi_string_alloc();
switch(subghz->txrx->rx_key_state) {
case SubGhzRxKeyStateBack:
@ -293,8 +288,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
subghz_protocol_raw_save_to_file_stop(
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result);
FuriString* temp_str;
temp_str = furi_string_alloc();
FuriString* temp_str = furi_string_alloc();
furi_string_printf(
temp_str, "%s/%s%s", SUBGHZ_RAW_FOLDER, RAW_FILE_NAME, SUBGHZ_APP_EXTENSION);
subghz_protocol_raw_gen_fff_data(

View file

@ -39,14 +39,10 @@ const NotificationSequence subghz_sequence_rx_locked = {
static void subghz_scene_receiver_update_statusbar(void* context) {
SubGhz* subghz = context;
FuriString* history_stat_str;
history_stat_str = furi_string_alloc();
FuriString* history_stat_str = furi_string_alloc();
if(!subghz_history_get_text_space_left(subghz->txrx->history, history_stat_str)) {
FuriString* frequency_str;
FuriString* modulation_str;
frequency_str = furi_string_alloc();
modulation_str = furi_string_alloc();
FuriString* frequency_str = furi_string_alloc();
FuriString* modulation_str = furi_string_alloc();
#ifdef SUBGHZ_EXT_PRESET_NAME
if(subghz_history_get_last_index(subghz->txrx->history) > 0) {
@ -90,12 +86,12 @@ static void subghz_scene_add_to_history_callback(
SubGhzProtocolDecoderBase* decoder_base,
void* context) {
furi_assert(context);
SubGhz* subghz = context;
FuriString* item_name;
FuriString* item_time;
FuriString* item_name = furi_string_alloc();
FuriString* item_time = furi_string_alloc();
uint16_t idx = subghz_history_get_item(subghz->txrx->history);
item_name = furi_string_alloc();
item_time = furi_string_alloc();
if(subghz_history_add_to_history(subghz->txrx->history, decoder_base, subghz->txrx->preset)) {
furi_string_reset(item_name);
@ -122,10 +118,8 @@ static void subghz_scene_add_to_history_callback(
void subghz_scene_receiver_on_enter(void* context) {
SubGhz* subghz = context;
FuriString* item_name;
FuriString* item_time;
item_name = furi_string_alloc();
item_time = furi_string_alloc();
FuriString* item_name = furi_string_alloc();
FuriString* item_time = furi_string_alloc();
if(subghz->txrx->rx_key_state == SubGhzRxKeyStateIDLE) {
subghz_preset_init(subghz, "AM650", subghz->last_settings->frequency, NULL, 0);

View file

@ -49,13 +49,9 @@ static bool subghz_scene_receiver_info_update_parser(void* context) {
void subghz_scene_receiver_info_draw_widget(SubGhz* subghz) {
if(subghz_scene_receiver_info_update_parser(subghz)) {
FuriString* frequency_str;
FuriString* modulation_str;
FuriString* text;
frequency_str = furi_string_alloc();
modulation_str = furi_string_alloc();
text = furi_string_alloc();
FuriString* frequency_str = furi_string_alloc();
FuriString* modulation_str = furi_string_alloc();
FuriString* text = furi_string_alloc();
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
widget_add_string_element(

View file

@ -72,8 +72,7 @@ bool subghz_scene_rpc_on_event(void* context, SceneManagerEvent event) {
subghz->scene_manager, SubGhzSceneRpc, SubGhzRpcStateLoaded);
furi_string_set(subghz->file_path, arg);
result = true;
FuriString* file_name;
file_name = furi_string_alloc();
FuriString* file_name = furi_string_alloc();
path_extract_filename(subghz->file_path, file_name, true);
snprintf(

View file

@ -51,10 +51,8 @@ void subghz_scene_save_name_on_enter(void* context) {
TextInput* text_input = subghz->text_input;
bool dev_name_empty = false;
FuriString* file_name;
FuriString* dir_name;
file_name = furi_string_alloc();
dir_name = furi_string_alloc();
FuriString* file_name = furi_string_alloc();
FuriString* dir_name = furi_string_alloc();
if(!subghz_path_is_file(subghz->file_path)) {
char file_name_buf[SUBGHZ_MAX_LEN_NAME] = {0};
@ -109,7 +107,7 @@ void subghz_scene_save_name_on_enter(void* context) {
subghz_scene_save_name_text_input_callback,
subghz,
subghz->file_name_tmp,
MAX_TEXT_INPUT_LEN, // buffer size
MAX_TEXT_INPUT_LEN,
dev_name_empty);
ValidatorIsFile* validator_is_file = validator_is_file_alloc_init(

View file

@ -16,13 +16,10 @@ bool subghz_scene_transmitter_update_data_show(void* context) {
SubGhz* subghz = context;
bool ret = false;
if(subghz->txrx->decoder_result) {
FuriString* key_str;
FuriString* frequency_str;
FuriString* modulation_str;
FuriString* key_str = furi_string_alloc();
FuriString* frequency_str = furi_string_alloc();
FuriString* modulation_str = furi_string_alloc();
key_str = furi_string_alloc();
frequency_str = furi_string_alloc();
modulation_str = furi_string_alloc();
bool show_button = false;
if(subghz_protocol_decoder_base_deserialize(

View file

@ -215,8 +215,7 @@ static void subghz_cli_command_rx_callback(
SubGhzCliCommandRx* instance = context;
instance->packet_count++;
FuriString* text;
text = furi_string_alloc();
FuriString* text = furi_string_alloc();
subghz_protocol_decoder_base_get_string(decoder_base, text);
subghz_receiver_reset(receiver);
printf("%s", furi_string_get_cstr(text));
@ -384,14 +383,12 @@ void subghz_cli_command_rx_raw(Cli* cli, FuriString* args, void* context) {
}
void subghz_cli_command_decode_raw(Cli* cli, FuriString* args, void* context) {
UNUSED(context);
FuriString* file_name;
file_name = furi_string_alloc();
FuriString* file_name = furi_string_alloc();
furi_string_set(file_name, ANY_PATH("subghz/test.sub"));
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
FuriString* temp_str;
temp_str = furi_string_alloc();
FuriString* temp_str = furi_string_alloc();
uint32_t temp_data32;
bool check_file = false;
@ -526,10 +523,8 @@ static void subghz_cli_command_encrypt_keeloq(Cli* cli, FuriString* args) {
UNUSED(cli);
uint8_t iv[16];
FuriString* source;
FuriString* destination;
source = furi_string_alloc();
destination = furi_string_alloc();
FuriString* source = furi_string_alloc();
FuriString* destination = furi_string_alloc();
SubGhzKeystore* keystore = subghz_keystore_alloc();
@ -569,10 +564,8 @@ static void subghz_cli_command_encrypt_raw(Cli* cli, FuriString* args) {
UNUSED(cli);
uint8_t iv[16];
FuriString* source;
FuriString* destination;
source = furi_string_alloc();
destination = furi_string_alloc();
FuriString* source = furi_string_alloc();
FuriString* destination = furi_string_alloc();
do {
if(!args_read_string_and_trim(args, source)) {
@ -645,14 +638,10 @@ static void subghz_cli_command_chat(Cli* cli, FuriString* args) {
size_t message_max_len = 64;
uint8_t message[64] = {0};
FuriString* input;
input = furi_string_alloc();
FuriString* name;
name = furi_string_alloc();
FuriString* output;
output = furi_string_alloc();
FuriString* sysmsg;
sysmsg = furi_string_alloc();
FuriString* input = furi_string_alloc();
FuriString* name = furi_string_alloc();
FuriString* output = furi_string_alloc();
FuriString* sysmsg = furi_string_alloc();
bool exit = false;
SubGhzChatEvent chat_event;
@ -785,8 +774,7 @@ static void subghz_cli_command_chat(Cli* cli, FuriString* args) {
}
static void subghz_cli_command(Cli* cli, FuriString* args, void* context) {
FuriString* cmd;
cmd = furi_string_alloc();
FuriString* cmd = furi_string_alloc();
do {
if(!args_read_string_and_trim(args, cmd)) {

View file

@ -197,8 +197,7 @@ bool subghz_history_add_to_history(
instance->code_last_hash_data = subghz_protocol_decoder_base_get_hash_data(decoder_base);
instance->last_update_timestamp = furi_get_tick();
FuriString* text;
text = furi_string_alloc();
FuriString* text = furi_string_alloc();
SubGhzHistoryItem* item = SubGhzHistoryItemArray_push_raw(instance->history->data);
item->preset = malloc(sizeof(SubGhzRadioPreset));
item->type = decoder_base->protocol->type;

View file

@ -145,8 +145,7 @@ bool subghz_tx_start(SubGhz* subghz, FlipperFormat* flipper_format) {
furi_assert(subghz);
bool ret = false;
FuriString* temp_str;
temp_str = furi_string_alloc();
FuriString* temp_str = furi_string_alloc();
uint32_t repeat = 200;
do {
if(!flipper_format_rewind(flipper_format)) {
@ -254,8 +253,7 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) {
Stream* fff_data_stream = flipper_format_get_raw_stream(subghz->txrx->fff_data);
SubGhzLoadKeyState load_key_state = SubGhzLoadKeyStateParseErr;
FuriString* temp_str;
temp_str = furi_string_alloc();
FuriString* temp_str = furi_string_alloc();
uint32_t temp_data32;
do {
@ -393,13 +391,9 @@ bool subghz_get_next_name_file(SubGhz* subghz, uint8_t max_len) {
furi_assert(subghz);
Storage* storage = furi_record_open(RECORD_STORAGE);
FuriString* temp_str;
FuriString* file_name;
FuriString* file_path;
temp_str = furi_string_alloc();
file_name = furi_string_alloc();
file_path = furi_string_alloc();
FuriString* temp_str = furi_string_alloc();
FuriString* file_name = furi_string_alloc();
FuriString* file_path = furi_string_alloc();
bool res = false;
@ -446,8 +440,7 @@ bool subghz_save_protocol_to_file(
Stream* flipper_format_stream = flipper_format_get_raw_stream(flipper_format);
bool saved = false;
FuriString* file_dir;
file_dir = furi_string_alloc();
FuriString* file_dir = furi_string_alloc();
path_extract_dirname(dev_file_name, file_dir);
do {
@ -478,8 +471,7 @@ bool subghz_save_protocol_to_file(
bool subghz_load_protocol_from_file(SubGhz* subghz) {
furi_assert(subghz);
FuriString* file_path;
file_path = furi_string_alloc();
FuriString* file_path = furi_string_alloc();
DialogsFileBrowserOptions browser_options;
dialog_file_browser_set_basic_options(&browser_options, SUBGHZ_APP_EXTENSION, &I_sub1_10px);

View file

@ -239,8 +239,7 @@ void subghz_view_receiver_draw(Canvas* canvas, SubGhzViewReceiverModel* model) {
}
bool scrollbar = model->history_item > 4;
FuriString* str_buff;
str_buff = furi_string_alloc();
FuriString* str_buff = furi_string_alloc();
SubGhzReceiverMenuItem* item_menu;