Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/flipperzero-firmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'applications')
-rw-r--r--applications/archive/archive.c2
-rw-r--r--applications/archive/views/archive_browser_view.c2
-rw-r--r--applications/bad_usb/bad_usb_app.c2
-rw-r--r--applications/bad_usb/bad_usb_script.c2
-rw-r--r--applications/bad_usb/views/bad_usb_view.c2
-rw-r--r--applications/bt/bt_debug_app/bt_debug_app.c2
-rwxr-xr-xapplications/bt/bt_debug_app/views/bt_carrier_test.c2
-rw-r--r--applications/bt/bt_debug_app/views/bt_packet_test.c2
-rwxr-xr-xapplications/bt/bt_debug_app/views/bt_test.c2
-rwxr-xr-xapplications/bt/bt_hid_app/bt_hid.c2
-rwxr-xr-xapplications/bt/bt_hid_app/views/bt_hid_keynote.c2
-rwxr-xr-xapplications/bt/bt_hid_app/views/bt_hid_media.c2
-rwxr-xr-xapplications/bt/bt_service/bt.c2
-rwxr-xr-xapplications/bt/bt_settings_app/bt_settings_app.c2
-rw-r--r--applications/cli/cli.c2
-rw-r--r--applications/crypto/crypto_cli.c6
-rw-r--r--applications/debug_tools/display_test/display_test.c2
-rw-r--r--applications/debug_tools/display_test/view_display_test.c2
-rw-r--r--applications/debug_tools/uart_echo.c6
-rw-r--r--applications/debug_tools/usb_test.c2
-rw-r--r--applications/desktop/animations/animation_manager.c2
-rw-r--r--applications/desktop/animations/animation_storage.c129
-rw-r--r--applications/desktop/animations/views/bubble_animation_view.c8
-rw-r--r--applications/desktop/animations/views/one_shot_animation_view.c2
-rw-r--r--applications/desktop/desktop.c2
-rw-r--r--applications/desktop/desktop_settings/desktop_settings_app.c2
-rw-r--r--applications/desktop/desktop_settings/views/desktop_settings_view_pin_setup_howto.c2
-rw-r--r--applications/desktop/desktop_settings/views/desktop_settings_view_pin_setup_howto2.c3
-rw-r--r--applications/desktop/scenes/desktop_scene_hw_mismatch.c2
-rw-r--r--applications/desktop/scenes/desktop_scene_pin_input.c2
-rw-r--r--applications/desktop/views/desktop_view_debug.c2
-rw-r--r--applications/desktop/views/desktop_view_first_start.c2
-rw-r--r--applications/desktop/views/desktop_view_lock_menu.c2
-rw-r--r--applications/desktop/views/desktop_view_locked.c2
-rw-r--r--applications/desktop/views/desktop_view_main.c2
-rw-r--r--applications/desktop/views/desktop_view_pin_input.c2
-rw-r--r--applications/desktop/views/desktop_view_pin_setup_done.c2
-rw-r--r--applications/desktop/views/desktop_view_pin_timeout.c2
-rw-r--r--applications/dialogs/dialogs.c2
-rw-r--r--applications/dialogs/dialogs_module_file_select.c5
-rw-r--r--applications/dialogs/dialogs_module_message.c6
-rw-r--r--applications/dialogs/view_holder.c4
-rw-r--r--applications/dolphin/dolphin.c2
-rw-r--r--applications/dolphin/helpers/dolphin_state.c2
-rw-r--r--applications/gpio/gpio_app.c2
-rw-r--r--applications/gpio/scenes/gpio_scene_usb_uart.c2
-rw-r--r--applications/gpio/scenes/gpio_scene_usb_uart_config.c2
-rw-r--r--applications/gpio/usb_uart_bridge.c2
-rwxr-xr-xapplications/gpio/views/gpio_test.c2
-rw-r--r--applications/gpio/views/gpio_usb_uart.c2
-rw-r--r--applications/gui/canvas.c2
-rw-r--r--applications/gui/gui.c2
-rw-r--r--applications/gui/icon_animation.c2
-rw-r--r--applications/gui/modules/button_menu.c2
-rw-r--r--applications/gui/modules/button_panel.c4
-rw-r--r--applications/gui/modules/byte_input.c2
-rw-r--r--applications/gui/modules/dialog.c2
-rwxr-xr-xapplications/gui/modules/dialog_ex.c2
-rw-r--r--applications/gui/modules/empty_screen.c4
-rw-r--r--applications/gui/modules/file_select.c10
-rw-r--r--applications/gui/modules/menu.c2
-rw-r--r--applications/gui/modules/popup.c2
-rw-r--r--applications/gui/modules/submenu.c2
-rwxr-xr-xapplications/gui/modules/text_box.c2
-rwxr-xr-xapplications/gui/modules/text_input.c2
-rw-r--r--applications/gui/modules/validators.c2
-rw-r--r--applications/gui/modules/variable_item_list.c2
-rwxr-xr-xapplications/gui/modules/widget.c2
-rw-r--r--applications/gui/modules/widget_elements/widget_element_button.c4
-rwxr-xr-xapplications/gui/modules/widget_elements/widget_element_frame.c4
-rw-r--r--applications/gui/modules/widget_elements/widget_element_icon.c4
-rwxr-xr-xapplications/gui/modules/widget_elements/widget_element_string.c4
-rw-r--r--applications/gui/modules/widget_elements/widget_element_string_multiline.c4
-rw-r--r--applications/gui/modules/widget_elements/widget_element_text_box.c4
-rwxr-xr-xapplications/gui/scene_manager.c162
-rw-r--r--applications/gui/view.c8
-rw-r--r--applications/gui/view_dispatcher.c2
-rw-r--r--applications/gui/view_port.c2
-rw-r--r--applications/gui/view_stack.c2
-rw-r--r--applications/ibutton/ibutton_app.cpp33
-rw-r--r--applications/input/input.c4
-rw-r--r--applications/irda/cli/irda_cli.cpp2
-rw-r--r--applications/irda/helpers/irda_parser.cpp51
-rw-r--r--applications/irda/helpers/irda_parser.h9
-rw-r--r--applications/irda/irda_app_brute_force.cpp19
-rw-r--r--applications/irda/irda_app_brute_force.h4
-rw-r--r--applications/irda/irda_app_remote_manager.cpp20
-rw-r--r--applications/irda/view/irda_app_brut_view.c2
-rw-r--r--applications/irda_monitor/irda_monitor.c2
-rw-r--r--applications/lfrfid/lfrfid_app.cpp33
-rw-r--r--applications/loader/loader.c2
-rwxr-xr-xapplications/nfc/helpers/nfc_emv_parser.c12
-rwxr-xr-xapplications/nfc/nfc.c2
-rwxr-xr-xapplications/nfc/nfc_device.c113
-rwxr-xr-xapplications/nfc/nfc_worker.c11
-rwxr-xr-xapplications/nfc/views/bank_card.c2
-rw-r--r--applications/notification/notification_app.c4
-rw-r--r--applications/notification/notification_settings_app.c2
-rwxr-xr-xapplications/power/battery_test_app/battery_test_app.c4
-rwxr-xr-xapplications/power/power_service/power.c2
-rwxr-xr-xapplications/power/power_service/views/power_off.c2
-rwxr-xr-xapplications/power/power_settings_app/power_settings_app.c2
-rw-r--r--applications/power/power_settings_app/views/battery_info.c2
-rw-r--r--applications/rpc/rpc.c8
-rw-r--r--applications/rpc/rpc_cli.c2
-rw-r--r--applications/rpc/rpc_gui.c8
-rw-r--r--applications/rpc/rpc_storage.c16
-rw-r--r--applications/rpc/rpc_system.c8
-rw-r--r--applications/snake_game/snake_game.c2
-rw-r--r--applications/storage/filesystem_api_defines.h1
-rw-r--r--applications/storage/storage_cli.c8
-rw-r--r--applications/storage/storage_external_api.c4
-rw-r--r--applications/storage/storage_test_app.c2
-rw-r--r--applications/storage/storages/storage_ext.c2
-rw-r--r--applications/storage/storages/storage_int.c10
-rw-r--r--applications/storage_settings/storage_settings.c2
-rw-r--r--applications/subghz/helpers/subghz_chat.c4
-rw-r--r--applications/subghz/helpers/subghz_frequency_analyzer_worker.c2
-rw-r--r--applications/subghz/subghz.c4
-rw-r--r--applications/subghz/subghz_cli.c2
-rw-r--r--applications/subghz/subghz_history.c2
-rwxr-xr-xapplications/subghz/subghz_i.c38
-rw-r--r--applications/subghz/views/subghz_frequency_analyzer.c4
-rw-r--r--applications/subghz/views/subghz_read_raw.c6
-rw-r--r--applications/subghz/views/subghz_receiver.c6
-rw-r--r--applications/subghz/views/subghz_test_carrier.c2
-rw-r--r--applications/subghz/views/subghz_test_packet.c2
-rw-r--r--applications/subghz/views/subghz_test_static.c4
-rw-r--r--applications/subghz/views/subghz_transmitter.c2
-rw-r--r--applications/system/system_settings.c2
-rw-r--r--applications/tests/flipper_format/flipper_format_string_test.c227
-rw-r--r--applications/tests/flipper_format/flipper_format_test.c (renamed from applications/tests/flipper_file/flipper_file_test.c)222
-rw-r--r--applications/tests/furi_memmgr_test.c3
-rw-r--r--applications/tests/irda_decoder_encoder/irda_decoder_encoder_test.c4
-rw-r--r--applications/tests/minunit.h20
-rw-r--r--applications/tests/rpc/rpc_test.c22
-rw-r--r--applications/tests/stream/stream_test.c381
-rw-r--r--applications/tests/test_index.c10
-rw-r--r--applications/u2f/u2f.c2
-rw-r--r--applications/u2f/u2f_app.c2
-rw-r--r--applications/u2f/u2f_data.c92
-rw-r--r--applications/u2f/u2f_hid.c2
-rw-r--r--applications/u2f/views/u2f_view.c2
143 files changed, 1314 insertions, 666 deletions
diff --git a/applications/archive/archive.c b/applications/archive/archive.c
index c2fe4c6d..79f26f0e 100644
--- a/applications/archive/archive.c
+++ b/applications/archive/archive.c
@@ -13,7 +13,7 @@ bool archive_back_event_callback(void* context) {
}
ArchiveApp* archive_alloc() {
- ArchiveApp* archive = furi_alloc(sizeof(ArchiveApp));
+ ArchiveApp* archive = malloc(sizeof(ArchiveApp));
archive->gui = furi_record_open("gui");
archive->text_input = text_input_alloc();
diff --git a/applications/archive/views/archive_browser_view.c b/applications/archive/views/archive_browser_view.c
index 5e079436..67a4ce02 100644
--- a/applications/archive/views/archive_browser_view.c
+++ b/applications/archive/views/archive_browser_view.c
@@ -305,7 +305,7 @@ bool archive_view_input(InputEvent* event, void* context) {
}
ArchiveBrowserView* browser_alloc() {
- ArchiveBrowserView* browser = furi_alloc(sizeof(ArchiveBrowserView));
+ ArchiveBrowserView* browser = malloc(sizeof(ArchiveBrowserView));
browser->view = view_alloc();
view_allocate_model(browser->view, ViewModelTypeLocking, sizeof(ArchiveBrowserViewModel));
view_set_context(browser->view, browser);
diff --git a/applications/bad_usb/bad_usb_app.c b/applications/bad_usb/bad_usb_app.c
index 49809562..adf9b7c8 100644
--- a/applications/bad_usb/bad_usb_app.c
+++ b/applications/bad_usb/bad_usb_app.c
@@ -41,7 +41,7 @@ static bool bad_usb_check_assets() {
}
BadUsbApp* bad_usb_app_alloc(char* arg) {
- BadUsbApp* app = furi_alloc(sizeof(BadUsbApp));
+ BadUsbApp* app = malloc(sizeof(BadUsbApp));
if(arg != NULL) {
string_t filename;
diff --git a/applications/bad_usb/bad_usb_script.c b/applications/bad_usb/bad_usb_script.c
index 53710372..07df2bd1 100644
--- a/applications/bad_usb/bad_usb_script.c
+++ b/applications/bad_usb/bad_usb_script.c
@@ -524,7 +524,7 @@ static int32_t bad_usb_worker(void* context) {
BadUsbScript* bad_usb_script_open(string_t file_path) {
furi_assert(file_path);
- BadUsbScript* bad_usb = furi_alloc(sizeof(BadUsbScript));
+ BadUsbScript* bad_usb = malloc(sizeof(BadUsbScript));
string_init(bad_usb->file_path);
string_set(bad_usb->file_path, file_path);
diff --git a/applications/bad_usb/views/bad_usb_view.c b/applications/bad_usb/views/bad_usb_view.c
index 6d226ca7..22e5143d 100644
--- a/applications/bad_usb/views/bad_usb_view.c
+++ b/applications/bad_usb/views/bad_usb_view.c
@@ -115,7 +115,7 @@ static bool bad_usb_input_callback(InputEvent* event, void* context) {
}
BadUsb* bad_usb_alloc() {
- BadUsb* bad_usb = furi_alloc(sizeof(BadUsb));
+ BadUsb* bad_usb = malloc(sizeof(BadUsb));
bad_usb->view = view_alloc();
view_allocate_model(bad_usb->view, ViewModelTypeLocking, sizeof(BadUsbModel));
diff --git a/applications/bt/bt_debug_app/bt_debug_app.c b/applications/bt/bt_debug_app/bt_debug_app.c
index 218692c0..a4363b91 100644
--- a/applications/bt/bt_debug_app/bt_debug_app.c
+++ b/applications/bt/bt_debug_app/bt_debug_app.c
@@ -27,7 +27,7 @@ uint32_t bt_debug_start_view(void* context) {
}
BtDebugApp* bt_debug_app_alloc() {
- BtDebugApp* app = furi_alloc(sizeof(BtDebugApp));
+ BtDebugApp* app = malloc(sizeof(BtDebugApp));
// Load settings
bt_settings_load(&app->settings);
diff --git a/applications/bt/bt_debug_app/views/bt_carrier_test.c b/applications/bt/bt_debug_app/views/bt_carrier_test.c
index a3dfd65c..22b80cd8 100755
--- a/applications/bt/bt_debug_app/views/bt_carrier_test.c
+++ b/applications/bt/bt_debug_app/views/bt_carrier_test.c
@@ -130,7 +130,7 @@ static void bt_test_carrier_timer_callback(void* context) {
}
BtCarrierTest* bt_carrier_test_alloc() {
- BtCarrierTest* bt_carrier_test = furi_alloc(sizeof(BtCarrierTest));
+ BtCarrierTest* bt_carrier_test = malloc(sizeof(BtCarrierTest));
bt_carrier_test->bt_test = bt_test_alloc();
bt_test_set_context(bt_carrier_test->bt_test, bt_carrier_test);
bt_test_set_change_state_callback(
diff --git a/applications/bt/bt_debug_app/views/bt_packet_test.c b/applications/bt/bt_debug_app/views/bt_packet_test.c
index 19dd6b21..e9d3883a 100644
--- a/applications/bt/bt_debug_app/views/bt_packet_test.c
+++ b/applications/bt/bt_debug_app/views/bt_packet_test.c
@@ -98,7 +98,7 @@ static void bt_test_packet_timer_callback(void* context) {
}
BtPacketTest* bt_packet_test_alloc() {
- BtPacketTest* bt_packet_test = furi_alloc(sizeof(BtPacketTest));
+ BtPacketTest* bt_packet_test = malloc(sizeof(BtPacketTest));
bt_packet_test->bt_test = bt_test_alloc();
bt_test_set_context(bt_packet_test->bt_test, bt_packet_test);
bt_test_set_change_state_callback(
diff --git a/applications/bt/bt_debug_app/views/bt_test.c b/applications/bt/bt_debug_app/views/bt_test.c
index 747ce6a4..ac10e0a8 100755
--- a/applications/bt/bt_debug_app/views/bt_test.c
+++ b/applications/bt/bt_debug_app/views/bt_test.c
@@ -291,7 +291,7 @@ void bt_test_process_back(BtTest* bt_test) {
}
BtTest* bt_test_alloc() {
- BtTest* bt_test = furi_alloc(sizeof(BtTest));
+ BtTest* bt_test = malloc(sizeof(BtTest));
bt_test->view = view_alloc();
view_set_context(bt_test->view, bt_test);
view_allocate_model(bt_test->view, ViewModelTypeLocking, sizeof(BtTestModel));
diff --git a/applications/bt/bt_hid_app/bt_hid.c b/applications/bt/bt_hid_app/bt_hid.c
index 9d6fdae7..ab13f6f3 100755
--- a/applications/bt/bt_hid_app/bt_hid.c
+++ b/applications/bt/bt_hid_app/bt_hid.c
@@ -54,7 +54,7 @@ void bt_hid_connection_status_changed_callback(BtStatus status, void* context) {
}
BtHid* bt_hid_app_alloc() {
- BtHid* app = furi_alloc(sizeof(BtHid));
+ BtHid* app = malloc(sizeof(BtHid));
// Gui
app->gui = furi_record_open("gui");
diff --git a/applications/bt/bt_hid_app/views/bt_hid_keynote.c b/applications/bt/bt_hid_app/views/bt_hid_keynote.c
index c9507726..c4225227 100755
--- a/applications/bt/bt_hid_app/views/bt_hid_keynote.c
+++ b/applications/bt/bt_hid_app/views/bt_hid_keynote.c
@@ -161,7 +161,7 @@ static bool bt_hid_keynote_input_callback(InputEvent* event, void* context) {
}
BtHidKeynote* bt_hid_keynote_alloc() {
- BtHidKeynote* bt_hid_keynote = furi_alloc(sizeof(BtHidKeynote));
+ BtHidKeynote* bt_hid_keynote = malloc(sizeof(BtHidKeynote));
bt_hid_keynote->view = view_alloc();
view_set_context(bt_hid_keynote->view, bt_hid_keynote);
view_allocate_model(bt_hid_keynote->view, ViewModelTypeLocking, sizeof(BtHidKeynoteModel));
diff --git a/applications/bt/bt_hid_app/views/bt_hid_media.c b/applications/bt/bt_hid_app/views/bt_hid_media.c
index 1b205b84..695ce3c3 100755
--- a/applications/bt/bt_hid_app/views/bt_hid_media.c
+++ b/applications/bt/bt_hid_app/views/bt_hid_media.c
@@ -162,7 +162,7 @@ static bool bt_hid_media_input_callback(InputEvent* event, void* context) {
}
BtHidMedia* bt_hid_media_alloc() {
- BtHidMedia* bt_hid_media = furi_alloc(sizeof(BtHidMedia));
+ BtHidMedia* bt_hid_media = malloc(sizeof(BtHidMedia));
bt_hid_media->view = view_alloc();
view_set_context(bt_hid_media->view, bt_hid_media);
view_allocate_model(bt_hid_media->view, ViewModelTypeLocking, sizeof(BtHidMediaModel));
diff --git a/applications/bt/bt_service/bt.c b/applications/bt/bt_service/bt.c
index 0015c08c..720f4854 100755
--- a/applications/bt/bt_service/bt.c
+++ b/applications/bt/bt_service/bt.c
@@ -101,7 +101,7 @@ static void bt_battery_level_changed_callback(const void* _event, void* context)
}
Bt* bt_alloc() {
- Bt* bt = furi_alloc(sizeof(Bt));
+ Bt* bt = malloc(sizeof(Bt));
// Init default maximum packet size
bt->max_packet_size = FURI_HAL_BT_SERIAL_PACKET_SIZE_MAX;
bt->profile = BtProfileSerial;
diff --git a/applications/bt/bt_settings_app/bt_settings_app.c b/applications/bt/bt_settings_app/bt_settings_app.c
index be57223e..d9dfa74d 100755
--- a/applications/bt/bt_settings_app/bt_settings_app.c
+++ b/applications/bt/bt_settings_app/bt_settings_app.c
@@ -13,7 +13,7 @@ static bool bt_settings_back_event_callback(void* context) {
}
BtSettingsApp* bt_settings_app_alloc() {
- BtSettingsApp* app = furi_alloc(sizeof(BtSettingsApp));
+ BtSettingsApp* app = malloc(sizeof(BtSettingsApp));
// Load settings
bt_settings_load(&app->settings);
diff --git a/applications/cli/cli.c b/applications/cli/cli.c
index dc2037d5..4b36521b 100644
--- a/applications/cli/cli.c
+++ b/applications/cli/cli.c
@@ -5,7 +5,7 @@
#include <loader/loader.h>
Cli* cli_alloc() {
- Cli* cli = furi_alloc(sizeof(Cli));
+ Cli* cli = malloc(sizeof(Cli));
CliCommandTree_init(cli->commands);
diff --git a/applications/crypto/crypto_cli.c b/applications/crypto/crypto_cli.c
index cd77fe61..60e32b2b 100644
--- a/applications/crypto/crypto_cli.c
+++ b/applications/crypto/crypto_cli.c
@@ -67,7 +67,7 @@ void crypto_cli_encrypt(Cli* cli, string_t args) {
size = size - remain + 16;
}
string_reserve(input, size);
- uint8_t* output = furi_alloc(size);
+ uint8_t* output = malloc(size);
if(!furi_hal_crypto_encrypt((const uint8_t*)string_get_cstr(input), output, size)) {
printf("Failed to encrypt input");
} else {
@@ -135,8 +135,8 @@ void crypto_cli_decrypt(Cli* cli, string_t args) {
size_t hex_size = string_size(hex_input);
if(hex_size > 0 && hex_size % 2 == 0) {
size_t size = hex_size / 2;
- uint8_t* input = furi_alloc(size);
- uint8_t* output = furi_alloc(size);
+ uint8_t* input = malloc(size);
+ uint8_t* output = malloc(size);
if(args_read_hex_bytes(hex_input, input, size)) {
if(furi_hal_crypto_decrypt(input, output, size)) {
diff --git a/applications/debug_tools/display_test/display_test.c b/applications/debug_tools/display_test/display_test.c
index 2efac325..1a9a0e43 100644
--- a/applications/debug_tools/display_test/display_test.c
+++ b/applications/debug_tools/display_test/display_test.c
@@ -121,7 +121,7 @@ static void display_config_set_contrast(VariableItem* item) {
}
DisplayTest* display_test_alloc() {
- DisplayTest* instance = furi_alloc(sizeof(DisplayTest));
+ DisplayTest* instance = malloc(sizeof(DisplayTest));
View* view = NULL;
diff --git a/applications/debug_tools/display_test/view_display_test.c b/applications/debug_tools/display_test/view_display_test.c
index 0ba6df80..cc5f5dcf 100644
--- a/applications/debug_tools/display_test/view_display_test.c
+++ b/applications/debug_tools/display_test/view_display_test.c
@@ -155,7 +155,7 @@ static void view_display_test_timer_callback(void* context) {
}
ViewDisplayTest* view_display_test_alloc() {
- ViewDisplayTest* instance = furi_alloc(sizeof(ViewDisplayTest));
+ ViewDisplayTest* instance = malloc(sizeof(ViewDisplayTest));
instance->view = view_alloc();
view_set_context(instance->view, instance);
diff --git a/applications/debug_tools/uart_echo.c b/applications/debug_tools/uart_echo.c
index 8c30a93c..73af1e66 100644
--- a/applications/debug_tools/uart_echo.c
+++ b/applications/debug_tools/uart_echo.c
@@ -178,7 +178,7 @@ static int32_t uart_echo_worker(void* context) {
}
static UartEchoApp* uart_echo_app_alloc() {
- UartEchoApp* app = furi_alloc(sizeof(UartEchoApp));
+ UartEchoApp* app = malloc(sizeof(UartEchoApp));
app->rx_stream = xStreamBufferCreate(2048, 1);
@@ -201,7 +201,7 @@ static UartEchoApp* uart_echo_app_alloc() {
for(size_t i = 0; i < LINES_ON_SCREEN; i++) {
model->line = 0;
model->escape = false;
- model->list[i] = furi_alloc(sizeof(ListElement));
+ model->list[i] = malloc(sizeof(ListElement));
string_init(model->list[i]->text);
}
return true;
@@ -265,4 +265,4 @@ int32_t uart_echo_app(void* p) {
view_dispatcher_run(app->view_dispatcher);
uart_echo_app_free(app);
return 0;
-} \ No newline at end of file
+}
diff --git a/applications/debug_tools/usb_test.c b/applications/debug_tools/usb_test.c
index ff32198a..cdc1aa40 100644
--- a/applications/debug_tools/usb_test.c
+++ b/applications/debug_tools/usb_test.c
@@ -47,7 +47,7 @@ uint32_t usb_test_exit(void* context) {
}
UsbTestApp* usb_test_app_alloc() {
- UsbTestApp* app = furi_alloc(sizeof(UsbTestApp));
+ UsbTestApp* app = malloc(sizeof(UsbTestApp));
// Gui
app->gui = furi_record_open("gui");
diff --git a/applications/desktop/animations/animation_manager.c b/applications/desktop/animations/animation_manager.c
index 1cb06d4f..afc9c42e 100644
--- a/applications/desktop/animations/animation_manager.c
+++ b/applications/desktop/animations/animation_manager.c
@@ -258,7 +258,7 @@ static void animation_manager_replace_current_animation(
}
AnimationManager* animation_manager_alloc(void) {
- AnimationManager* animation_manager = furi_alloc(sizeof(AnimationManager));
+ AnimationManager* animation_manager = malloc(sizeof(AnimationManager));
animation_manager->animation_view = bubble_animation_view_alloc();
animation_manager->view_stack = view_stack_alloc();
View* animation_view = bubble_animation_get_view(animation_manager->animation_view);
diff --git a/applications/desktop/animations/animation_storage.c b/applications/desktop/animations/animation_storage.c
index 24c0aab1..aa0f274b 100644
--- a/applications/desktop/animations/animation_storage.c
+++ b/applications/desktop/animations/animation_storage.c
@@ -1,6 +1,6 @@
#include <stdint.h>
-#include <flipper_file.h>
+#include <flipper_format/flipper_format.h>
#include <furi.h>
#include <furi/dangerous_defines.h>
#include <storage/storage.h>
@@ -30,41 +30,41 @@ static bool animation_storage_load_single_manifest_info(
bool result = false;
Storage* storage = furi_record_open("storage");
- FlipperFile* file = flipper_file_alloc(storage);
- flipper_file_set_strict_mode(file, true);
+ FlipperFormat* file = flipper_format_file_alloc(storage);
+ flipper_format_set_strict_mode(file, true);
string_t read_string;
string_init(read_string);
do {
uint32_t u32value;
if(FSE_OK != storage_sd_status(storage)) break;
- if(!flipper_file_open_existing(file, ANIMATION_MANIFEST_FILE)) break;
+ if(!flipper_format_file_open_existing(file, ANIMATION_MANIFEST_FILE)) break;
- if(!flipper_file_read_header(file, read_string, &u32value)) break;
+ if(!flipper_format_read_header(file, read_string, &u32value)) break;
if(string_cmp_str(read_string, "Flipper Animation Manifest")) break;
manifest_info->name = NULL;
/* skip other animation names */
- flipper_file_set_strict_mode(file, false);
- while(flipper_file_read_string(file, "Name", read_string) &&
+ flipper_format_set_strict_mode(file, false);
+ while(flipper_format_read_string(file, "Name", read_string) &&
string_cmp_str(read_string, name))
;
if(string_cmp_str(read_string, name)) break;
- flipper_file_set_strict_mode(file, true);
+ flipper_format_set_strict_mode(file, true);
- manifest_info->name = furi_alloc(string_size(read_string) + 1);
+ manifest_info->name = malloc(string_size(read_string) + 1);
strcpy((char*)manifest_info->name, string_get_cstr(read_string));
- if(!flipper_file_read_uint32(file, "Min butthurt", &u32value, 1)) break;
+ if(!flipper_format_read_uint32(file, "Min butthurt", &u32value, 1)) break;
manifest_info->min_butthurt = u32value;
- if(!flipper_file_read_uint32(file, "Max butthurt", &u32value, 1)) break;
+ if(!flipper_format_read_uint32(file, "Max butthurt", &u32value, 1)) break;
manifest_info->max_butthurt = u32value;
- if(!flipper_file_read_uint32(file, "Min level", &u32value, 1)) break;
+ if(!flipper_format_read_uint32(file, "Min level", &u32value, 1)) break;
manifest_info->min_level = u32value;
- if(!flipper_file_read_uint32(file, "Max level", &u32value, 1)) break;
+ if(!flipper_format_read_uint32(file, "Max level", &u32value, 1)) break;
manifest_info->max_level = u32value;
- if(!flipper_file_read_uint32(file, "Weight", &u32value, 1)) break;
+ if(!flipper_format_read_uint32(file, "Weight", &u32value, 1)) break;
manifest_info->weight = u32value;
result = true;
} while(0);
@@ -73,8 +73,7 @@ static bool animation_storage_load_single_manifest_info(
free((void*)manifest_info->name);
}
string_clear(read_string);
- flipper_file_close(file);
- flipper_file_free(file);
+ flipper_format_free(file);
furi_record_close("storage");
@@ -86,9 +85,9 @@ void animation_storage_fill_animation_list(StorageAnimationList_t* animation_lis
furi_assert(!StorageAnimationList_size(*animation_list));
Storage* storage = furi_record_open("storage");
- FlipperFile* file = flipper_file_alloc(storage);
+ FlipperFormat* file = flipper_format_file_alloc(storage);
/* Forbid skipping fields */
- flipper_file_set_strict_mode(file, true);
+ flipper_format_set_strict_mode(file, true);
string_t read_string;
string_init(read_string);
@@ -97,28 +96,28 @@ void animation_storage_fill_animation_list(StorageAnimationList_t* animation_lis
StorageAnimation* storage_animation = NULL;
if(FSE_OK != storage_sd_status(storage)) break;
- if(!flipper_file_open_existing(file, ANIMATION_MANIFEST_FILE)) break;
- if(!flipper_file_read_header(file, read_string, &u32value)) break;
+ if(!flipper_format_file_open_existing(file, ANIMATION_MANIFEST_FILE)) break;
+ if(!flipper_format_read_header(file, read_string, &u32value)) break;
if(string_cmp_str(read_string, "Flipper Animation Manifest")) break;
do {
- storage_animation = furi_alloc(sizeof(StorageAnimation));
+ storage_animation = malloc(sizeof(StorageAnimation));
storage_animation->external = true;
storage_animation->animation = NULL;
storage_animation->manifest_info.name = NULL;
- if(!flipper_file_read_string(file, "Name", read_string)) break;
- storage_animation->manifest_info.name = furi_alloc(string_size(read_string) + 1);
+ if(!flipper_format_read_string(file, "Name", read_string)) break;
+ storage_animation->manifest_info.name = malloc(string_size(read_string) + 1);
strcpy((char*)storage_animation->manifest_info.name, string_get_cstr(read_string));
- if(!flipper_file_read_uint32(file, "Min butthurt", &u32value, 1)) break;
+ if(!flipper_format_read_uint32(file, "Min butthurt", &u32value, 1)) break;
storage_animation->manifest_info.min_butthurt = u32value;
- if(!flipper_file_read_uint32(file, "Max butthurt", &u32value, 1)) break;
+ if(!flipper_format_read_uint32(file, "Max butthurt", &u32value, 1)) break;
storage_animation->manifest_info.max_butthurt = u32value;
- if(!flipper_file_read_uint32(file, "Min level", &u32value, 1)) break;
+ if(!flipper_format_read_uint32(file, "Min level", &u32value, 1)) break;
storage_animation->manifest_info.min_level = u32value;
- if(!flipper_file_read_uint32(file, "Max level", &u32value, 1)) break;
+ if(!flipper_format_read_uint32(file, "Max level", &u32value, 1)) break;
storage_animation->manifest_info.max_level = u32value;
- if(!flipper_file_read_uint32(file, "Weight", &u32value, 1)) break;
+ if(!flipper_format_read_uint32(file, "Weight", &u32value, 1)) break;
storage_animation->manifest_info.weight = u32value;
StorageAnimationList_push_back(*animation_list, storage_animation);
@@ -128,8 +127,7 @@ void animation_storage_fill_animation_list(StorageAnimationList_t* animation_lis
} while(0);
string_clear(read_string);
- flipper_file_close(file);
- flipper_file_free(file);
+ flipper_format_free(file);
// add hard-coded animations
for(int i = 0; i < dolphin_internal_size; ++i) {
@@ -162,7 +160,7 @@ StorageAnimation* animation_storage_find_animation(const char* name) {
/* look through external animations */
if(!storage_animation) {
- storage_animation = furi_alloc(sizeof(StorageAnimation));
+ storage_animation = malloc(sizeof(StorageAnimation));
storage_animation->external = true;
bool result = false;
@@ -288,7 +286,7 @@ static bool animation_storage_load_frames(
FURI_CONST_ASSIGN(icon->frame_rate, 0);
FURI_CONST_ASSIGN(icon->height, height);
FURI_CONST_ASSIGN(icon->width, width);
- icon->frames = furi_alloc(sizeof(const uint8_t*) * icon->frame_count);
+ icon->frames = malloc(sizeof(const uint8_t*) * icon->frame_count);
bool frames_ok = false;
File* file = storage_file_alloc(storage);
@@ -317,7 +315,7 @@ static bool animation_storage_load_frames(
break;
}
- FURI_CONST_ASSIGN_PTR(icon->frames[i], furi_alloc(file_info.size));
+ FURI_CONST_ASSIGN_PTR(icon->frames[i], malloc(file_info.size));
if(storage_file_read(file, (void*)icon->frames[i], file_info.size) != file_info.size) {
FURI_LOG_E(TAG, "Read failed: \'%s\'", string_get_cstr(filename));
break;
@@ -348,7 +346,7 @@ static bool animation_storage_load_frames(
return frames_ok;
}
-static bool animation_storage_load_bubbles(BubbleAnimation* animation, FlipperFile* ff) {
+static bool animation_storage_load_bubbles(BubbleAnimation* animation, FlipperFormat* ff) {
uint32_t u32value;
string_t str;
string_init(str);
@@ -356,7 +354,7 @@ static bool animation_storage_load_bubbles(BubbleAnimation* animation, FlipperFi
furi_assert(!animation->frame_bubble_sequences);
do {
- if(!flipper_file_read_uint32(ff, "Bubble slots", &u32value, 1)) break;
+ if(!flipper_format_read_uint32(ff, "Bubble slots", &u32value, 1)) break;
if(u32value > 20) break;
animation->frame_bubble_sequences_count = u32value;
if(animation->frame_bubble_sequences_count == 0) {
@@ -365,22 +363,22 @@ static bool animation_storage_load_bubbles(BubbleAnimation* animation, FlipperFi
break;
}
animation->frame_bubble_sequences =
- furi_alloc(sizeof(FrameBubble*) * animation->frame_bubble_sequences_count);
+ malloc(sizeof(FrameBubble*) * animation->frame_bubble_sequences_count);
uint32_t current_slot = 0;
for(int i = 0; i < animation->frame_bubble_sequences_count; ++i) {
FURI_CONST_ASSIGN_PTR(
- animation->frame_bubble_sequences[i], furi_alloc(sizeof(FrameBubble)));
+ animation->frame_bubble_sequences[i], malloc(sizeof(FrameBubble)));
}
const FrameBubble* bubble = animation->frame_bubble_sequences[0];
int8_t index = -1;
for(;;) {
- if(!flipper_file_read_uint32(ff, "Slot", &current_slot, 1)) break;
+ if(!flipper_format_read_uint32(ff, "Slot", &current_slot, 1)) break;
if((current_slot != 0) && (index == -1)) break;
if(current_slot == index) {
- FURI_CONST_ASSIGN_PTR(bubble->next_bubble, furi_alloc(sizeof(FrameBubble)));
+ FURI_CONST_ASSIGN_PTR(bubble->next_bubble, malloc(sizeof(FrameBubble)));
bubble = bubble->next_bubble;
} else if(current_slot == index + 1) {
++index;
@@ -392,27 +390,27 @@ static bool animation_storage_load_bubbles(BubbleAnimation* animation, FlipperFi
}
if(index >= animation->frame_bubble_sequences_count) break;
- if(!flipper_file_read_uint32(ff, "X", &u32value, 1)) break;
+ if(!flipper_format_read_uint32(ff, "X", &u32value, 1)) break;
FURI_CONST_ASSIGN(bubble->bubble.x, u32value);
- if(!flipper_file_read_uint32(ff, "Y", &u32value, 1)) break;
+ if(!flipper_format_read_uint32(ff, "Y", &u32value, 1)) break;
FURI_CONST_ASSIGN(bubble->bubble.y, u32value);
- if(!flipper_file_read_string(ff, "Text", str)) break;
+ if(!flipper_format_read_string(ff, "Text", str)) break;
if(string_size(str) > 100) break;
string_replace_all_str(str, "\\n", "\n");
- FURI_CONST_ASSIGN_PTR(bubble->bubble.text, furi_alloc(string_size(str) + 1));
+ FURI_CONST_ASSIGN_PTR(bubble->bubble.text, malloc(string_size(str) + 1));
strcpy((char*)bubble->bubble.text, string_get_cstr(str));
- if(!flipper_file_read_string(ff, "AlignH", str)) break;
+ if(!flipper_format_read_string(ff, "AlignH", str)) break;
if(!animation_storage_cast_align(str, (Align*)&bubble->bubble.align_h)) break;
- if(!flipper_file_read_string(ff, "AlignV", str)) break;
+ if(!flipper_format_read_string(ff, "AlignV", str)) break;
if(!animation_storage_cast_align(str, (Align*)&bubble->bubble.align_v)) break;
- if(!flipper_file_read_uint32(ff, "StartFrame", &u32value, 1)) break;
+ if(!flipper_format_read_uint32(ff, "StartFrame", &u32value, 1)) break;
FURI_CONST_ASSIGN(bubble->start_frame, u32value);
- if(!flipper_file_read_uint32(ff, "EndFrame", &u32value, 1)) break;
+ if(!flipper_format_read_uint32(ff, "EndFrame", &u32value, 1)) break;
FURI_CONST_ASSIGN(bubble->end_frame, u32value);
}
success = (index + 1) == animation->frame_bubble_sequences_count;
@@ -431,15 +429,15 @@ static bool animation_storage_load_bubbles(BubbleAnimation* animation, FlipperFi
static BubbleAnimation* animation_storage_load_animation(const char* name) {
furi_assert(name);
- BubbleAnimation* animation = furi_alloc(sizeof(BubbleAnimation));
+ BubbleAnimation* animation = malloc(sizeof(BubbleAnimation));
uint32_t height = 0;
uint32_t width = 0;
uint32_t* u32array = NULL;
Storage* storage = furi_record_open("storage");
- FlipperFile* ff = flipper_file_alloc(storage);
+ FlipperFormat* ff = flipper_format_file_alloc(storage);
/* Forbid skipping fields */
- flipper_file_set_strict_mode(ff, true);
+ flipper_format_set_strict_mode(ff, true);
string_t str;
string_init(str);
animation->frame_bubble_sequences = NULL;
@@ -451,28 +449,28 @@ static BubbleAnimation* animation_storage_load_animation(const char* name) {
if(FSE_OK != storage_sd_status(storage)) break;
string_printf(str, ANIMATION_DIR "/%s/" ANIMATION_META_FILE, name);
- if(!flipper_file_open_existing(ff, string_get_cstr(str))) break;
- if(!flipper_file_read_header(ff, str, &u32value)) break;
+ if(!flipper_format_file_open_existing(ff, string_get_cstr(str))) break;
+ if(!flipper_format_read_header(ff, str, &u32value)) break;
if(string_cmp_str(str, "Flipper Animation")) break;
- if(!flipper_file_read_uint32(ff, "Width", &width, 1)) break;
- if(!flipper_file_read_uint32(ff, "Height", &height, 1)) break;
+ if(!flipper_format_read_uint32(ff, "Width", &width, 1)) break;
+ if(!flipper_format_read_uint32(ff, "Height", &height, 1)) break;
- if(!flipper_file_read_uint32(ff, "Passive frames", &u32value, 1)) break;
+ if(!flipper_format_read_uint32(ff, "Passive frames", &u32value, 1)) break;
animation->passive_frames = u32value;
- if(!flipper_file_read_uint32(ff, "Active frames", &u32value, 1)) break;
+ if(!flipper_format_read_uint32(ff, "Active frames", &u32value, 1)) break;
animation->active_frames = u32value;
uint8_t frames = animation->passive_frames + animation->active_frames;
uint32_t count = 0;
- if(!flipper_file_get_value_count(ff, "Frames order", &count)) break;
+ if(!flipper_format_get_value_count(ff, "Frames order", &count)) break;
if(count != frames) {
FURI_LOG_E(TAG, "Error loading animation: frames order");
break;
}
- u32array = furi_alloc(sizeof(uint32_t) * frames);
- if(!flipper_file_read_uint32(ff, "Frames order", u32array, frames)) break;
- animation->frame_order = furi_alloc(sizeof(uint8_t) * frames);
+ u32array = malloc(sizeof(uint32_t) * frames);
+ if(!flipper_format_read_uint32(ff, "Frames order", u32array, frames)) break;
+ animation->frame_order = malloc(sizeof(uint8_t) * frames);
for(int i = 0; i < frames; ++i) {
FURI_CONST_ASSIGN(animation->frame_order[i], u32array[i]);
}
@@ -481,13 +479,13 @@ static BubbleAnimation* animation_storage_load_animation(const char* name) {
if(!animation_storage_load_frames(storage, name, animation, u32array, width, height))
break;
- if(!flipper_file_read_uint32(ff, "Active cycles", &u32value, 1)) break;
+ if(!flipper_format_read_uint32(ff, "Active cycles", &u32value, 1)) break;
animation->active_cycles = u32value;
- if(!flipper_file_read_uint32(ff, "Frame rate", &u32value, 1)) break;
+ if(!flipper_format_read_uint32(ff, "Frame rate", &u32value, 1)) break;
FURI_CONST_ASSIGN(animation->icon_animation.frame_rate, u32value);
- if(!flipper_file_read_uint32(ff, "Duration", &u32value, 1)) break;
+ if(!flipper_format_read_uint32(ff, "Duration", &u32value, 1)) break;
animation->duration = u32value;
- if(!flipper_file_read_uint32(ff, "Active cooldown", &u32value, 1)) break;
+ if(!flipper_format_read_uint32(ff, "Active cooldown", &u32value, 1)) break;
animation->active_cooldown = u32value;
if(!animation_storage_load_bubbles(animation, ff)) break;
@@ -495,8 +493,7 @@ static BubbleAnimation* animation_storage_load_animation(const char* name) {
} while(0);
string_clear(str);
- flipper_file_close(ff);
- flipper_file_free(ff);
+ flipper_format_free(ff);
if(u32array) {
free(u32array);
}
diff --git a/applications/desktop/animations/views/bubble_animation_view.c b/applications/desktop/animations/views/bubble_animation_view.c
index 596f0aa1..9b60d45c 100644
--- a/applications/desktop/animations/views/bubble_animation_view.c
+++ b/applications/desktop/animations/views/bubble_animation_view.c
@@ -256,17 +256,17 @@ static Icon* bubble_animation_clone_first_frame(const Icon* icon_orig) {
furi_assert(icon_orig->frames);
furi_assert(icon_orig->frames[0]);
- Icon* icon_clone = furi_alloc(sizeof(Icon));
+ Icon* icon_clone = malloc(sizeof(Icon));
memcpy(icon_clone, icon_orig, sizeof(Icon));
- icon_clone->frames = furi_alloc(sizeof(uint8_t*));
+ icon_clone->frames = malloc(sizeof(uint8_t*));
/* icon bitmap can be either compressed or not. It is compressed if
* compressed size is less than original, so max size for bitmap is
* uncompressed (width * height) + 1 byte (in uncompressed case)
* for compressed header
*/
size_t max_bitmap_size = ROUND_UP_TO(icon_orig->width, 8) * icon_orig->height + 1;
- FURI_CONST_ASSIGN_PTR(icon_clone->frames[0], furi_alloc(max_bitmap_size));
+ FURI_CONST_ASSIGN_PTR(icon_clone->frames[0], malloc(max_bitmap_size));
memcpy((void*)icon_clone->frames[0], icon_orig->frames[0], max_bitmap_size);
FURI_CONST_ASSIGN(icon_clone->frame_count, 1);
@@ -304,7 +304,7 @@ static void bubble_animation_exit(void* context) {
}
BubbleAnimationView* bubble_animation_view_alloc(void) {
- BubbleAnimationView* view = furi_alloc(sizeof(BubbleAnimationView));
+ BubbleAnimationView* view = malloc(sizeof(BubbleAnimationView));
view->view = view_alloc();
view->interact_callback = NULL;
view->timer = osTimerNew(bubble_animation_timer_callback, osTimerPeriodic, view, NULL);
diff --git a/applications/desktop/animations/views/one_shot_animation_view.c b/applications/desktop/animations/views/one_shot_animation_view.c
index d7e9915a..9a4dff06 100644
--- a/applications/desktop/animations/views/one_shot_animation_view.c
+++ b/applications/desktop/animations/views/one_shot_animation_view.c
@@ -78,7 +78,7 @@ static bool one_shot_view_input(InputEvent* event, void* context) {
}
OneShotView* one_shot_view_alloc(void) {
- OneShotView* view = furi_alloc(sizeof(OneShotView));
+ OneShotView* view = malloc(sizeof(OneShotView));
view->view = view_alloc();
view->update_timer =
xTimerCreate(NULL, 1000, pdTRUE, view, one_shot_view_update_timer_callback);
diff --git a/applications/desktop/desktop.c b/applications/desktop/desktop.c
index b3d80e7a..1e3edf77 100644
--- a/applications/desktop/desktop.c
+++ b/applications/desktop/desktop.c
@@ -39,7 +39,7 @@ static void desktop_tick_event_callback(void* context) {
}
Desktop* desktop_alloc() {
- Desktop* desktop = furi_alloc(sizeof(Desktop));
+ Desktop* desktop = malloc(sizeof(Desktop));
desktop->unload_animation_semaphore = osSemaphoreNew(1, 0, NULL);
desktop->animation_manager = animation_manager_alloc();
diff --git a/applications/desktop/desktop_settings/desktop_settings_app.c b/applications/desktop/desktop_settings/desktop_settings_app.c
index ca078ccd..46e0bdc5 100644
--- a/applications/desktop/desktop_settings/desktop_settings_app.c
+++ b/applications/desktop/desktop_settings/desktop_settings_app.c
@@ -19,7 +19,7 @@ static bool desktop_settings_back_event_callback(void* context) {
}
DesktopSettingsApp* desktop_settings_app_alloc() {
- DesktopSettingsApp* app = furi_alloc(sizeof(DesktopSettingsApp));
+ DesktopSettingsApp* app = malloc(sizeof(DesktopSettingsApp));
app->gui = furi_record_open("gui");
app->view_dispatcher = view_dispatcher_alloc();
diff --git a/applications/desktop/desktop_settings/views/desktop_settings_view_pin_setup_howto.c b/applications/desktop/desktop_settings/views/desktop_settings_view_pin_setup_howto.c
index c87de756..3831be8c 100644
--- a/applications/desktop/desktop_settings/views/desktop_settings_view_pin_setup_howto.c
+++ b/applications/desktop/desktop_settings/views/desktop_settings_view_pin_setup_howto.c
@@ -55,7 +55,7 @@ void desktop_settings_view_pin_setup_howto_set_callback(
}
DesktopSettingsViewPinSetupHowto* desktop_settings_view_pin_setup_howto_alloc() {
- DesktopSettingsViewPinSetupHowto* view = furi_alloc(sizeof(DesktopSettingsViewPinSetupHowto));
+ DesktopSettingsViewPinSetupHowto* view = malloc(sizeof(DesktopSettingsViewPinSetupHowto));
view->view = view_alloc();
view_allocate_model(view->view, ViewModelTypeLockFree, 1);
view_set_context(view->view, view);
diff --git a/applications/desktop/desktop_settings/views/desktop_settings_view_pin_setup_howto2.c b/applications/desktop/desktop_settings/views/desktop_settings_view_pin_setup_howto2.c
index 3ef22b46..ab1fa238 100644
--- a/applications/desktop/desktop_settings/views/desktop_settings_view_pin_setup_howto2.c
+++ b/applications/desktop/desktop_settings/views/desktop_settings_view_pin_setup_howto2.c
@@ -77,8 +77,7 @@ void desktop_settings_view_pin_setup_howto2_set_ok_callback(
}
DesktopSettingsViewPinSetupHowto2* desktop_settings_view_pin_setup_howto2_alloc() {
- DesktopSettingsViewPinSetupHowto2* view =
- furi_alloc(sizeof(DesktopSettingsViewPinSetupHowto2));
+ DesktopSettingsViewPinSetupHowto2* view = malloc(sizeof(DesktopSettingsViewPinSetupHowto2));
view->view = view_alloc();
view_allocate_model(view->view, ViewModelTypeLockFree, 1);
view_set_context(view->view, view);
diff --git a/applications/desktop/scenes/desktop_scene_hw_mismatch.c b/applications/desktop/scenes/desktop_scene_hw_mismatch.c
index 05a6fd68..35c50610 100644
--- a/applications/desktop/scenes/desktop_scene_hw_mismatch.c
+++ b/applications/desktop/scenes/desktop_scene_hw_mismatch.c
@@ -16,7 +16,7 @@ void desktop_scene_hw_mismatch_on_enter(void* context) {
furi_assert(desktop);
Popup* popup = desktop->hw_mismatch_popup;
- char* text_buffer = furi_alloc(256);
+ char* text_buffer = malloc(256);
scene_manager_set_scene_state(
desktop->scene_manager, DesktopSceneHwMismatch, (uint32_t)text_buffer);
diff --git a/applications/desktop/scenes/desktop_scene_pin_input.c b/applications/desktop/scenes/desktop_scene_pin_input.c
index 8d714ff9..5a0f63f0 100644
--- a/applications/desktop/scenes/desktop_scene_pin_input.c
+++ b/applications/desktop/scenes/desktop_scene_pin_input.c
@@ -80,7 +80,7 @@ void desktop_scene_pin_input_on_enter(void* context) {
desktop_view_pin_input_set_done_callback(
desktop->pin_input_view, desktop_scene_pin_input_done_callback);
- DesktopScenePinInputState* state = furi_alloc(sizeof(DesktopScenePinInputState));
+ DesktopScenePinInputState* state = malloc(sizeof(DesktopScenePinInputState));
state->timer =
xTimerCreate(NULL, 10000, pdFALSE, desktop, desktop_scene_pin_input_timer_callback);
scene_manager_set_scene_state(desktop->scene_manager, DesktopScenePinInput, (uint32_t)state);
diff --git a/applications/desktop/views/desktop_view_debug.c b/applications/desktop/views/desktop_view_debug.c
index 0ffd8d17..4cb8e8ea 100644
--- a/applications/desktop/views/desktop_view_debug.c
+++ b/applications/desktop/views/desktop_view_debug.c
@@ -150,7 +150,7 @@ bool desktop_debug_input(InputEvent* event, void* context) {
}
DesktopDebugView* desktop_debug_alloc() {
- DesktopDebugView* debug_view = furi_alloc(sizeof(DesktopDebugView));
+ DesktopDebugView* debug_view = malloc(sizeof(DesktopDebugView));
debug_view->view = view_alloc();
view_allocate_model(debug_view->view, ViewModelTypeLocking, sizeof(DesktopDebugViewModel));
view_set_context(debug_view->view, debug_view);
diff --git a/applications/desktop/views/desktop_view_first_start.c b/applications/desktop/views/desktop_view_first_start.c
index 5408dac0..87c07ad2 100644
--- a/applications/desktop/views/desktop_view_first_start.c
+++ b/applications/desktop/views/desktop_view_first_start.c
@@ -131,7 +131,7 @@ static void desktop_first_start_exit(void* context) {
}
DesktopFirstStartView* desktop_first_start_alloc() {
- DesktopFirstStartView* instance = furi_alloc(sizeof(DesktopFirstStartView));
+ DesktopFirstStartView* instance = malloc(sizeof(DesktopFirstStartView));
instance->view = view_alloc();
view_allocate_model(instance->view, ViewModelTypeLocking, sizeof(DesktopFirstStartViewModel));
view_set_context(instance->view, instance);
diff --git a/applications/desktop/views/desktop_view_lock_menu.c b/applications/desktop/views/desktop_view_lock_menu.c
index 005512cf..1b2bd76b 100644
--- a/applications/desktop/views/desktop_view_lock_menu.c
+++ b/applications/desktop/views/desktop_view_lock_menu.c
@@ -112,7 +112,7 @@ bool desktop_lock_menu_input(InputEvent* event, void* context) {
}
DesktopLockMenuView* desktop_lock_menu_alloc() {
- DesktopLockMenuView* lock_menu = furi_alloc(sizeof(DesktopLockMenuView));
+ DesktopLockMenuView* lock_menu = malloc(sizeof(DesktopLockMenuView));
lock_menu->view = view_alloc();
view_allocate_model(lock_menu->view, ViewModelTypeLocking, sizeof(DesktopLockMenuViewModel));
view_set_context(lock_menu->view, lock_menu);
diff --git a/applications/desktop/views/desktop_view_locked.c b/applications/desktop/views/desktop_view_locked.c
index 8e3f22ee..766f2b20 100644
--- a/applications/desktop/views/desktop_view_locked.c
+++ b/applications/desktop/views/desktop_view_locked.c
@@ -184,7 +184,7 @@ static bool desktop_view_locked_input(InputEvent* event, void* context) {
}
DesktopViewLocked* desktop_view_locked_alloc() {
- DesktopViewLocked* locked_view = furi_alloc(sizeof(DesktopViewLocked));
+ DesktopViewLocked* locked_view = malloc(sizeof(DesktopViewLocked));
locked_view->view = view_alloc();
locked_view->timer =
xTimerCreate(NULL, 1000 / 16, pdTRUE, locked_view, locked_view_timer_callback);
diff --git a/applications/desktop/views/desktop_view_main.c b/applications/desktop/views/desktop_view_main.c
index 51520863..091b0855 100644
--- a/applications/desktop/views/desktop_view_main.c
+++ b/applications/desktop/views/desktop_view_main.c
@@ -58,7 +58,7 @@ bool desktop_main_input(InputEvent* event, void* context) {
}
DesktopMainView* desktop_main_alloc() {
- DesktopMainView* main_view = furi_alloc(sizeof(DesktopMainView));
+ DesktopMainView* main_view = malloc(sizeof(DesktopMainView));
main_view->view = view_alloc();
view_allocate_model(main_view->view, ViewModelTypeLockFree, 1);
diff --git a/applications/desktop/views/desktop_view_pin_input.c b/applications/desktop/views/desktop_view_pin_input.c
index b8976ca2..11af5f4a 100644
--- a/applications/desktop/views/desktop_view_pin_input.c
+++ b/applications/desktop/views/desktop_view_pin_input.c
@@ -185,7 +185,7 @@ static void desktop_view_pin_input_exit(void* context) {
}
DesktopViewPinInput* desktop_view_pin_input_alloc(void) {
- DesktopViewPinInput* pin_input = furi_alloc(sizeof(DesktopViewPinInput));
+ DesktopViewPinInput* pin_input = malloc(sizeof(DesktopViewPinInput));
pin_input->view = view_alloc();
view_allocate_model(pin_input->view, ViewModelTypeLocking, sizeof(DesktopViewPinInputModel));
view_set_context(pin_input->view, pin_input);
diff --git a/applications/desktop/views/desktop_view_pin_setup_done.c b/applications/desktop/views/desktop_view_pin_setup_done.c
index a90903e9..1d82aeaa 100644
--- a/applications/desktop/views/desktop_view_pin_setup_done.c
+++ b/applications/desktop/views/desktop_view_pin_setup_done.c
@@ -57,7 +57,7 @@ void desktop_view_pin_done_set_callback(
}
DesktopViewPinSetupDone* desktop_view_pin_done_alloc() {
- DesktopViewPinSetupDone* view = furi_alloc(sizeof(DesktopViewPinSetupDone));
+ DesktopViewPinSetupDone* view = malloc(sizeof(DesktopViewPinSetupDone));
view->view = view_alloc();
view_allocate_model(view->view, ViewModelTypeLockFree, 1);
view_set_context(view->view, view);
diff --git a/applications/desktop/views/desktop_view_pin_timeout.c b/applications/desktop/views/desktop_view_pin_timeout.c
index 7cc0860f..d9827339 100644
--- a/applications/desktop/views/desktop_view_pin_timeout.c
+++ b/applications/desktop/views/desktop_view_pin_timeout.c
@@ -77,7 +77,7 @@ void desktop_view_pin_timeout_free(DesktopViewPinTimeout* instance) {
}
DesktopViewPinTimeout* desktop_view_pin_timeout_alloc(void) {
- DesktopViewPinTimeout* instance = furi_alloc(sizeof(DesktopViewPinTimeout));
+ DesktopViewPinTimeout* instance = malloc(sizeof(DesktopViewPinTimeout));
instance->timer = xTimerCreate(
NULL, pdMS_TO_TICKS(1000), pdTRUE, instance, desktop_view_pin_timeout_timer_callback);
diff --git a/applications/dialogs/dialogs.c b/applications/dialogs/dialogs.c
index 660b646f..2c8d2418 100644
--- a/applications/dialogs/dialogs.c
+++ b/applications/dialogs/dialogs.c
@@ -36,4 +36,4 @@ int32_t dialogs_srv(void* p) {
}
return 0;
-} \ No newline at end of file
+}
diff --git a/applications/dialogs/dialogs_module_file_select.c b/applications/dialogs/dialogs_module_file_select.c
index 177ecdef..f133c00a 100644
--- a/applications/dialogs/dialogs_module_file_select.c
+++ b/applications/dialogs/dialogs_module_file_select.c
@@ -25,8 +25,7 @@ bool dialogs_app_process_module_file_select(const DialogsAppMessageDataFileSelec
bool ret = false;
Gui* gui = furi_record_open("gui");
- DialogsAppFileSelectContext* file_select_context =
- furi_alloc(sizeof(DialogsAppFileSelectContext));
+ DialogsAppFileSelectContext* file_select_context = malloc(sizeof(DialogsAppFileSelectContext));
file_select_context->lock = API_LOCK_INIT_LOCKED();
ViewHolder* view_holder = view_holder_alloc();
@@ -57,4 +56,4 @@ bool dialogs_app_process_module_file_select(const DialogsAppMessageDataFileSelec
furi_record_close("gui");
return ret;
-} \ No newline at end of file
+}
diff --git a/applications/dialogs/dialogs_module_message.c b/applications/dialogs/dialogs_module_message.c
index 045d8692..2607940f 100644
--- a/applications/dialogs/dialogs_module_message.c
+++ b/applications/dialogs/dialogs_module_message.c
@@ -54,7 +54,7 @@ DialogMessageButton dialogs_app_process_module_message(const DialogsAppMessageDa
DialogMessageButton ret = DialogMessageButtonBack;
Gui* gui = furi_record_open("gui");
const DialogMessage* message = data->message;
- DialogsAppMessageContext* message_context = furi_alloc(sizeof(DialogsAppMessageContext));
+ DialogsAppMessageContext* message_context = malloc(sizeof(DialogsAppMessageContext));
message_context->lock = API_LOCK_INIT_LOCKED();
ViewHolder* view_holder = view_holder_alloc();
@@ -100,7 +100,7 @@ DialogMessageButton dialogs_app_process_module_message(const DialogsAppMessageDa
}
DialogMessage* dialog_message_alloc() {
- DialogMessage* message = furi_alloc(sizeof(DialogMessage));
+ DialogMessage* message = malloc(sizeof(DialogMessage));
return message;
}
@@ -150,4 +150,4 @@ void dialog_message_set_buttons(
message->left_button_text = left;
message->center_button_text = center;
message->right_button_text = right;
-} \ No newline at end of file
+}
diff --git a/applications/dialogs/view_holder.c b/applications/dialogs/view_holder.c
index 577f5282..eb8a1502 100644
--- a/applications/dialogs/view_holder.c
+++ b/applications/dialogs/view_holder.c
@@ -21,7 +21,7 @@ static void view_holder_draw_callback(Canvas* canvas, void* context);
static void view_holder_input_callback(InputEvent* event, void* context);
ViewHolder* view_holder_alloc() {
- ViewHolder* view_holder = furi_alloc(sizeof(ViewHolder));
+ ViewHolder* view_holder = malloc(sizeof(ViewHolder));
view_holder->view_port = view_port_alloc();
view_port_draw_callback_set(view_holder->view_port, view_holder_draw_callback, view_holder);
@@ -147,4 +147,4 @@ static void view_holder_input_callback(InputEvent* event, void* context) {
}
}
}
-} \ No newline at end of file
+}
diff --git a/applications/dolphin/dolphin.c b/applications/dolphin/dolphin.c
index 92c6d7a7..60068aff 100644
--- a/applications/dolphin/dolphin.c
+++ b/applications/dolphin/dolphin.c
@@ -74,7 +74,7 @@ void dolphin_clear_limits_timer_callback(TimerHandle_t xTimer) {
}
Dolphin* dolphin_alloc() {
- Dolphin* dolphin = furi_alloc(sizeof(Dolphin));
+ Dolphin* dolphin = malloc(sizeof(Dolphin));
dolphin->state = dolphin_state_alloc();
dolphin->event_queue = osMessageQueueNew(8, sizeof(DolphinEvent), NULL);
diff --git a/applications/dolphin/helpers/dolphin_state.c b/applications/dolphin/helpers/dolphin_state.c
index a14b106d..08a7dae3 100644
--- a/applications/dolphin/helpers/dolphin_state.c
+++ b/applications/dolphin/helpers/dolphin_state.c
@@ -17,7 +17,7 @@
#define BUTTHURT_MIN 0
DolphinState* dolphin_state_alloc() {
- return furi_alloc(sizeof(DolphinState));
+ return malloc(sizeof(DolphinState));
}
void dolphin_state_free(DolphinState* dolphin_state) {
diff --git a/applications/gpio/gpio_app.c b/applications/gpio/gpio_app.c
index ba7a230e..489c9854 100644
--- a/applications/gpio/gpio_app.c
+++ b/applications/gpio/gpio_app.c
@@ -22,7 +22,7 @@ static void gpio_app_tick_event_callback(void* context) {
}
GpioApp* gpio_app_alloc() {
- GpioApp* app = furi_alloc(sizeof(GpioApp));
+ GpioApp* app = malloc(sizeof(GpioApp));
app->gui = furi_record_open("gui");
diff --git a/applications/gpio/scenes/gpio_scene_usb_uart.c b/applications/gpio/scenes/gpio_scene_usb_uart.c
index 2e34bc8d..e2babcac 100644
--- a/applications/gpio/scenes/gpio_scene_usb_uart.c
+++ b/applications/gpio/scenes/gpio_scene_usb_uart.c
@@ -18,7 +18,7 @@ void gpio_scene_usb_uart_on_enter(void* context) {
GpioApp* app = context;
uint32_t prev_state = scene_manager_get_scene_state(app->scene_manager, GpioAppViewUsbUart);
if(prev_state == 0) {
- scene_usb_uart = furi_alloc(sizeof(SceneUsbUartBridge));
+ scene_usb_uart = malloc(sizeof(SceneUsbUartBridge));
scene_usb_uart->cfg.vcp_ch = 0; // TODO: settings load
scene_usb_uart->cfg.uart_ch = 0;
scene_usb_uart->cfg.flow_pins = 0;
diff --git a/applications/gpio/scenes/gpio_scene_usb_uart_config.c b/applications/gpio/scenes/gpio_scene_usb_uart_config.c
index 72f6db69..6fba0d1e 100644
--- a/applications/gpio/scenes/gpio_scene_usb_uart_config.c
+++ b/applications/gpio/scenes/gpio_scene_usb_uart_config.c
@@ -91,7 +91,7 @@ void gpio_scene_usb_uart_cfg_on_enter(void* context) {
GpioApp* app = context;
VariableItemList* var_item_list = app->var_item_list;
- cfg_set = furi_alloc(sizeof(UsbUartConfig));
+ cfg_set = malloc(sizeof(UsbUartConfig));
usb_uart_get_config(app->usb_uart_bridge, cfg_set);
VariableItem* item;
diff --git a/applications/gpio/usb_uart_bridge.c b/applications/gpio/usb_uart_bridge.c
index c9085af7..e8762ca9 100644
--- a/applications/gpio/usb_uart_bridge.c
+++ b/applications/gpio/usb_uart_bridge.c
@@ -312,7 +312,7 @@ static void vcp_on_line_config(void* context, struct usb_cdc_line_coding* config
}
UsbUartBridge* usb_uart_enable(UsbUartConfig* cfg) {
- UsbUartBridge* usb_uart = furi_alloc(sizeof(UsbUartBridge));
+ UsbUartBridge* usb_uart = malloc(sizeof(UsbUartBridge));
memcpy(&(usb_uart->cfg_new), cfg, sizeof(UsbUartConfig));
diff --git a/applications/gpio/views/gpio_test.c b/applications/gpio/views/gpio_test.c
index 62f3426e..cf05dafa 100755
--- a/applications/gpio/views/gpio_test.c
+++ b/applications/gpio/views/gpio_test.c
@@ -96,7 +96,7 @@ static bool gpio_test_process_ok(GpioTest* gpio_test, InputEvent* event) {
}
GpioTest* gpio_test_alloc() {
- GpioTest* gpio_test = furi_alloc(sizeof(GpioTest));
+ GpioTest* gpio_test = malloc(sizeof(GpioTest));
gpio_test->view = view_alloc();
view_allocate_model(gpio_test->view, ViewModelTypeLocking, sizeof(GpioTestModel));
diff --git a/applications/gpio/views/gpio_usb_uart.c b/applications/gpio/views/gpio_usb_uart.c
index be80f019..cd507570 100644
--- a/applications/gpio/views/gpio_usb_uart.c
+++ b/applications/gpio/views/gpio_usb_uart.c
@@ -102,7 +102,7 @@ static bool gpio_usb_uart_input_callback(InputEvent* event, void* context) {
}
GpioUsbUart* gpio_usb_uart_alloc() {
- GpioUsbUart* usb_uart = furi_alloc(sizeof(GpioUsbUart));
+ GpioUsbUart* usb_uart = malloc(sizeof(GpioUsbUart));
usb_uart->view = view_alloc();
view_allocate_model(usb_uart->view, ViewModelTypeLocking, sizeof(GpioUsbUartModel));
diff --git a/applications/gui/canvas.c b/applications/gui/canvas.c
index 3706b176..fe07bd5e 100644
--- a/applications/gui/canvas.c
+++ b/applications/gui/canvas.c
@@ -15,7 +15,7 @@ const CanvasFontParameters canvas_font_params[FontTotalNumber] = {
};
Canvas* canvas_init() {
- Canvas* canvas = furi_alloc(sizeof(Canvas));
+ Canvas* canvas = malloc(sizeof(Canvas));
furi_hal_power_insomnia_enter();
diff --git a/applications/gui/gui.c b/applications/gui/gui.c
index bc333bb1..7d34f5e2 100644
--- a/applications/gui/gui.c
+++ b/applications/gui/gui.c
@@ -417,7 +417,7 @@ void gui_set_lockdown(Gui* gui, bool lockdown) {
}
Gui* gui_alloc() {
- Gui* gui = furi_alloc(sizeof(Gui));
+ Gui* gui = malloc(sizeof(Gui));
// Thread ID
gui->thread = osThreadGetId();
// Allocate mutex
diff --git a/applications/gui/icon_animation.c b/applications/gui/icon_animation.c
index 530f3fa7..5170eea4 100644
--- a/applications/gui/icon_animation.c
+++ b/applications/gui/icon_animation.c
@@ -5,7 +5,7 @@
IconAnimation* icon_animation_alloc(const Icon* icon) {
furi_assert(icon);
- IconAnimation* instance = furi_alloc(sizeof(IconAnimation));
+ IconAnimation* instance = malloc(sizeof(IconAnimation));
instance->icon = icon;
instance->timer = osTimerNew(icon_animation_timer_callback, osTimerPeriodic, instance, NULL);
return instance;
diff --git a/applications/gui/modules/button_menu.c b/applications/gui/modules/button_menu.c
index e8bbb6a1..0f379b74 100644
--- a/applications/gui/modules/button_menu.c
+++ b/applications/gui/modules/button_menu.c
@@ -290,7 +290,7 @@ ButtonMenuItem* button_menu_add_item(
}
ButtonMenu* button_menu_alloc(void) {
- ButtonMenu* button_menu = furi_alloc(sizeof(ButtonMenu));
+ ButtonMenu* button_menu = malloc(sizeof(ButtonMenu));
button_menu->view = view_alloc();
view_set_orientation(button_menu->view, ViewOrientationVertical);
view_set_context(button_menu->view, button_menu);
diff --git a/applications/gui/modules/button_panel.c b/applications/gui/modules/button_panel.c
index 075e0c76..07bb6b62 100644
--- a/applications/gui/modules/button_panel.c
+++ b/applications/gui/modules/button_panel.c
@@ -65,7 +65,7 @@ static void button_panel_view_draw_callback(Canvas* canvas, void* _model);
static bool button_panel_view_input_callback(InputEvent* event, void* context);
ButtonPanel* button_panel_alloc() {
- ButtonPanel* button_panel = furi_alloc(sizeof(ButtonPanel));
+ ButtonPanel* button_panel = malloc(sizeof(ButtonPanel));
button_panel->view = view_alloc();
view_set_orientation(button_panel->view, ViewOrientationVertical);
view_set_context(button_panel->view, button_panel);
@@ -173,7 +173,7 @@ void button_panel_add_item(
ButtonItem** button_item_ptr =
button_panel_get_item(model, matrix_place_x, matrix_place_y);
furi_check(*button_item_ptr == NULL);
- *button_item_ptr = furi_alloc(sizeof(ButtonItem));
+ *button_item_ptr = malloc(sizeof(ButtonItem));
ButtonItem* button_item = *button_item_ptr;
button_item->callback = callback;
button_item->callback_context = callback_context;
diff --git a/applications/gui/modules/byte_input.c b/applications/gui/modules/byte_input.c
index b116030f..bb18a107 100644
--- a/applications/gui/modules/byte_input.c
+++ b/applications/gui/modules/byte_input.c
@@ -695,7 +695,7 @@ static void byte_input_reset_model_input_data(ByteInputModel* model) {
* @return ByteInput instance pointer
*/
ByteInput* byte_input_alloc() {
- ByteInput* byte_input = furi_alloc(sizeof(ByteInput));
+ ByteInput* byte_input = malloc(sizeof(ByteInput));
byte_input->view = view_alloc();
view_set_context(byte_input->view, byte_input);
view_allocate_model(byte_input->view, ViewModelTypeLocking, sizeof(ByteInputModel));
diff --git a/applications/gui/modules/dialog.c b/applications/gui/modules/dialog.c
index af649086..5d36f93f 100644
--- a/applications/gui/modules/dialog.c
+++ b/applications/gui/modules/dialog.c
@@ -60,7 +60,7 @@ static bool dialog_view_input_callback(InputEvent* event, void* context) {
}
Dialog* dialog_alloc() {
- Dialog* dialog = furi_alloc(sizeof(Dialog));
+ Dialog* dialog = malloc(sizeof(Dialog));
dialog->view = view_alloc();
view_set_context(dialog->view, dialog);
view_allocate_model(dialog->view, ViewModelTypeLockFree, sizeof(DialogModel));
diff --git a/applications/gui/modules/dialog_ex.c b/applications/gui/modules/dialog_ex.c
index 5dd0e410..6be455f8 100755
--- a/applications/gui/modules/dialog_ex.c
+++ b/applications/gui/modules/dialog_ex.c
@@ -114,7 +114,7 @@ static bool dialog_ex_view_input_callback(InputEvent* event, void* context) {
}
DialogEx* dialog_ex_alloc() {
- DialogEx* dialog_ex = furi_alloc(sizeof(DialogEx));
+ DialogEx* dialog_ex = malloc(sizeof(DialogEx));
dialog_ex->view = view_alloc();
view_set_context(dialog_ex->view, dialog_ex);
view_allocate_model(dialog_ex->view, ViewModelTypeLockFree, sizeof(DialogExModel));
diff --git a/applications/gui/modules/empty_screen.c b/applications/gui/modules/empty_screen.c
index a887786d..61b4af36 100644
--- a/applications/gui/modules/empty_screen.c
+++ b/applications/gui/modules/empty_screen.c
@@ -14,7 +14,7 @@ static bool empty_screen_view_input_callback(InputEvent* event, void* context) {
}
EmptyScreen* empty_screen_alloc() {
- EmptyScreen* empty_screen = furi_alloc(sizeof(EmptyScreen));
+ EmptyScreen* empty_screen = malloc(sizeof(EmptyScreen));
empty_screen->view = view_alloc();
view_set_context(empty_screen->view, empty_screen);
view_set_draw_callback(empty_screen->view, empty_screen_view_draw_callback);
@@ -31,4 +31,4 @@ void empty_screen_free(EmptyScreen* empty_screen) {
View* empty_screen_get_view(EmptyScreen* empty_screen) {
furi_assert(empty_screen);
return empty_screen->view;
-} \ No newline at end of file
+}
diff --git a/applications/gui/modules/file_select.c b/applications/gui/modules/file_select.c
index 78ecd241..14541196 100644
--- a/applications/gui/modules/file_select.c
+++ b/applications/gui/modules/file_select.c
@@ -181,7 +181,7 @@ static bool file_select_init_inner(FileSelect* file_select) {
}
FileSelect* file_select_alloc() {
- FileSelect* file_select = furi_alloc(sizeof(FileSelect));
+ FileSelect* file_select = malloc(sizeof(FileSelect));
file_select->view = view_alloc();
file_select->fs_api = furi_record_open("storage");
@@ -278,7 +278,7 @@ bool file_select_fill_strings(FileSelect* file_select) {
uint8_t string_counter = 0;
uint16_t file_counter = 0;
const uint8_t name_length = 100;
- char* name = furi_alloc(name_length);
+ char* name = malloc(name_length);
uint16_t first_file_index = 0;
with_view_model(
@@ -346,7 +346,7 @@ bool file_select_fill_count(FileSelect* file_select) {
uint16_t file_counter = 0;
const uint8_t name_length = 100;
- char* name = furi_alloc(name_length);
+ char* name = malloc(name_length);
if(!storage_dir_open(directory, file_select->path)) {
storage_dir_close(directory);
@@ -397,7 +397,7 @@ void file_select_set_selected_file_internal(FileSelect* file_select, const char*
File* directory = storage_file_alloc(file_select->fs_api);
const uint8_t name_length = 100;
- char* name = furi_alloc(name_length);
+ char* name = malloc(name_length);
uint16_t file_position = 0;
bool file_found = false;
@@ -472,4 +472,4 @@ void file_select_set_selected_file(FileSelect* file_select, const char* filename
if(!file_select_fill_strings(file_select)) {
file_select->callback(false, file_select->context);
}
-} \ No newline at end of file
+}
diff --git a/applications/gui/modules/menu.c b/applications/gui/modules/menu.c
index 0fb95d70..67d46d5f 100644
--- a/applications/gui/modules/menu.c
+++ b/applications/gui/modules/menu.c
@@ -125,7 +125,7 @@ static void menu_exit(void* context) {
}
Menu* menu_alloc() {
- Menu* menu = furi_alloc(sizeof(Menu));
+ Menu* menu = malloc(sizeof(Menu));
menu->view = view_alloc(menu->view);
view_set_context(menu->view, menu);
view_allocate_model(menu->view, ViewModelTypeLocking, sizeof(MenuModel));
diff --git a/applications/gui/modules/popup.c b/applications/gui/modules/popup.c
index 0e3b3889..3b53d962 100644
--- a/applications/gui/modules/popup.c
+++ b/applications/gui/modules/popup.c
@@ -108,7 +108,7 @@ void popup_stop_timer(void* context) {
}
Popup* popup_alloc() {
- Popup* popup = furi_alloc(sizeof(Popup));
+ Popup* popup = malloc(sizeof(Popup));
popup->view = view_alloc();
popup->timer = osTimerNew(popup_timer_callback, osTimerOnce, popup, NULL);
furi_assert(popup->timer);
diff --git a/applications/gui/modules/submenu.c b/applications/gui/modules/submenu.c
index e9e27203..9fefeca0 100644
--- a/applications/gui/modules/submenu.c
+++ b/applications/gui/modules/submenu.c
@@ -120,7 +120,7 @@ static bool submenu_view_input_callback(InputEvent* event, void* context) {
}
Submenu* submenu_alloc() {
- Submenu* submenu = furi_alloc(sizeof(Submenu));
+ Submenu* submenu = malloc(sizeof(Submenu));
submenu->view = view_alloc();
view_set_context(submenu->view, submenu);
view_allocate_model(submenu->view, ViewModelTypeLocking, sizeof(SubmenuModel));
diff --git a/applications/gui/modules/text_box.c b/applications/gui/modules/text_box.c
index 7e7eacd6..e2a99c22 100755
--- a/applications/gui/modules/text_box.c
+++ b/applications/gui/modules/text_box.c
@@ -128,7 +128,7 @@ static bool text_box_view_input_callback(InputEvent* event, void* context) {
}
TextBox* text_box_alloc() {
- TextBox* text_box = furi_alloc(sizeof(TextBox));
+ TextBox* text_box = malloc(sizeof(TextBox));
text_box->view = view_alloc();
view_set_context(text_box->view, text_box);
view_allocate_model(text_box->view, ViewModelTypeLocking, sizeof(TextBoxModel));
diff --git a/applications/gui/modules/text_input.c b/applications/gui/modules/text_input.c
index bb200606..d42f9dcf 100755
--- a/applications/gui/modules/text_input.c
+++ b/applications/gui/modules/text_input.c
@@ -410,7 +410,7 @@ void text_input_timer_callback(void* context) {
}
TextInput* text_input_alloc() {
- TextInput* text_input = furi_alloc(sizeof(TextInput));
+ TextInput* text_input = malloc(sizeof(TextInput));
text_input->view = view_alloc();
view_set_context(text_input->view, text_input);
view_allocate_model(text_input->view, ViewModelTypeLocking, sizeof(TextInputModel));
diff --git a/applications/gui/modules/validators.c b/applications/gui/modules/validators.c
index dc752e95..df0be729 100644
--- a/applications/gui/modules/validators.c
+++ b/applications/gui/modules/validators.c
@@ -28,7 +28,7 @@ bool validator_is_file_callback(const char* text, string_t error, void* context)
ValidatorIsFile*
validator_is_file_alloc_init(const char* app_path_folder, const char* app_extension) {
- ValidatorIsFile* instance = furi_alloc(sizeof(ValidatorIsFile));
+ ValidatorIsFile* instance = malloc(sizeof(ValidatorIsFile));
instance->app_path_folder = app_path_folder;
instance->app_extension = app_extension;
diff --git a/applications/gui/modules/variable_item_list.c b/applications/gui/modules/variable_item_list.c
index cf2b01a1..ebbdd434 100644
--- a/applications/gui/modules/variable_item_list.c
+++ b/applications/gui/modules/variable_item_list.c
@@ -276,7 +276,7 @@ void variable_item_list_process_ok(VariableItemList* variable_item_list) {
}
VariableItemList* variable_item_list_alloc() {
- VariableItemList* variable_item_list = furi_alloc(sizeof(VariableItemList));
+ VariableItemList* variable_item_list = malloc(sizeof(VariableItemList));
variable_item_list->view = view_alloc();
view_set_context(variable_item_list->view, variable_item_list);
view_allocate_model(
diff --git a/applications/gui/modules/widget.c b/applications/gui/modules/widget.c
index d6c50aaa..09729ee6 100755
--- a/applications/gui/modules/widget.c
+++ b/applications/gui/modules/widget.c
@@ -52,7 +52,7 @@ static bool gui_widget_view_input_callback(InputEvent* event, void* context) {
}
Widget* widget_alloc() {
- Widget* widget = furi_alloc(sizeof(Widget));
+ Widget* widget = malloc(sizeof(Widget));
widget->view = view_alloc();
view_set_context(widget->view, widget);
view_allocate_model(widget->view, ViewModelTypeLocking, sizeof(GuiWidgetModel));
diff --git a/applications/gui/modules/widget_elements/widget_element_button.c b/applications/gui/modules/widget_elements/widget_element_button.c
index 2fbfb892..92be2590 100644
--- a/applications/gui/modules/widget_elements/widget_element_button.c
+++ b/applications/gui/modules/widget_elements/widget_element_button.c
@@ -61,14 +61,14 @@ WidgetElement* widget_element_button_create(
ButtonCallback callback,
void* context) {
// Allocate and init model
- GuiButtonModel* model = furi_alloc(sizeof(GuiButtonModel));
+ GuiButtonModel* model = malloc(sizeof(GuiButtonModel));
model->button_type = button_type;
model->callback = callback;
model->context = context;
string_init_set_str(model->text, text);
// Allocate and init Element
- WidgetElement* gui_button = furi_alloc(sizeof(WidgetElement));
+ WidgetElement* gui_button = malloc(sizeof(WidgetElement));
gui_button->parent = NULL;
gui_button->input = gui_button_input;
gui_button->draw = gui_button_draw;
diff --git a/applications/gui/modules/widget_elements/widget_element_frame.c b/applications/gui/modules/widget_elements/widget_element_frame.c
index a8e00d9a..a7265348 100755
--- a/applications/gui/modules/widget_elements/widget_element_frame.c
+++ b/applications/gui/modules/widget_elements/widget_element_frame.c
@@ -29,7 +29,7 @@ WidgetElement* widget_element_frame_create(
uint8_t height,
uint8_t radius) {
// Allocate and init model
- GuiFrameModel* model = furi_alloc(sizeof(GuiFrameModel));
+ GuiFrameModel* model = malloc(sizeof(GuiFrameModel));
model->x = x;
model->y = y;
model->width = width;
@@ -37,7 +37,7 @@ WidgetElement* widget_element_frame_create(
model->radius = radius;
// Allocate and init Element
- WidgetElement* gui_frame = furi_alloc(sizeof(WidgetElement));
+ WidgetElement* gui_frame = malloc(sizeof(WidgetElement));
gui_frame->parent = NULL;
gui_frame->input = NULL;
gui_frame->draw = gui_frame_draw;
diff --git a/applications/gui/modules/widget_elements/widget_element_icon.c b/applications/gui/modules/widget_elements/widget_element_icon.c
index e9ff3a97..1340f48f 100644
--- a/applications/gui/modules/widget_elements/widget_element_icon.c
+++ b/applications/gui/modules/widget_elements/widget_element_icon.c
@@ -27,13 +27,13 @@ WidgetElement* widget_element_icon_create(uint8_t x, uint8_t y, const Icon* icon
furi_assert(icon);
// Allocate and init model
- GuiIconModel* model = furi_alloc(sizeof(GuiIconModel));
+ GuiIconModel* model = malloc(sizeof(GuiIconModel));
model->x = x;
model->y = y;
model->icon = icon;
// Allocate and init Element
- WidgetElement* gui_icon = furi_alloc(sizeof(WidgetElement));
+ WidgetElement* gui_icon = malloc(sizeof(WidgetElement));
gui_icon->parent = NULL;
gui_icon->input = NULL;
gui_icon->draw = gui_icon_draw;
diff --git a/applications/gui/modules/widget_elements/widget_element_string.c b/applications/gui/modules/widget_elements/widget_element_string.c
index e81cd439..a03c2b6d 100755
--- a/applications/gui/modules/widget_elements/widget_element_string.c
+++ b/applications/gui/modules/widget_elements/widget_element_string.c
@@ -46,7 +46,7 @@ WidgetElement* widget_element_string_create(
furi_assert(text);
// Allocate and init model
- GuiStringModel* model = furi_alloc(sizeof(GuiStringModel));
+ GuiStringModel* model = malloc(sizeof(GuiStringModel));
model->x = x;
model->y = y;
model->horizontal = horizontal;
@@ -55,7 +55,7 @@ WidgetElement* widget_element_string_create(
string_init_set_str(model->text, text);
// Allocate and init Element
- WidgetElement* gui_string = furi_alloc(sizeof(WidgetElement));
+ WidgetElement* gui_string = malloc(sizeof(WidgetElement));
gui_string->parent = NULL;
gui_string->input = NULL;
gui_string->draw = gui_string_draw;
diff --git a/applications/gui/modules/widget_elements/widget_element_string_multiline.c b/applications/gui/modules/widget_elements/widget_element_string_multiline.c
index f37eb3fc..01a70a0d 100644
--- a/applications/gui/modules/widget_elements/widget_element_string_multiline.c
+++ b/applications/gui/modules/widget_elements/widget_element_string_multiline.c
@@ -47,7 +47,7 @@ WidgetElement* widget_element_string_multiline_create(
furi_assert(text);
// Allocate and init model
- GuiStringMultiLineModel* model = furi_alloc(sizeof(GuiStringMultiLineModel));
+ GuiStringMultiLineModel* model = malloc(sizeof(GuiStringMultiLineModel));
model->x = x;
model->y = y;
model->horizontal = horizontal;
@@ -56,7 +56,7 @@ WidgetElement* widget_element_string_multiline_create(
string_init_set_str(model->text, text);
// Allocate and init Element
- WidgetElement* gui_string = furi_alloc(sizeof(WidgetElement));
+ WidgetElement* gui_string = malloc(sizeof(WidgetElement));
gui_string->parent = NULL;
gui_string->input = NULL;
gui_string->draw = gui_string_multiline_draw;
diff --git a/applications/gui/modules/widget_elements/widget_element_text_box.c b/applications/gui/modules/widget_elements/widget_element_text_box.c
index 9ee33188..a4dee5f6 100644
--- a/applications/gui/modules/widget_elements/widget_element_text_box.c
+++ b/applications/gui/modules/widget_elements/widget_element_text_box.c
@@ -50,7 +50,7 @@ WidgetElement* widget_element_text_box_create(
furi_assert(text);
// Allocate and init model
- GuiTextBoxModel* model = furi_alloc(sizeof(GuiTextBoxModel));
+ GuiTextBoxModel* model = malloc(sizeof(GuiTextBoxModel));
model->x = x;
model->y = y;
model->width = width;
@@ -60,7 +60,7 @@ WidgetElement* widget_element_text_box_create(
string_init_set_str(model->text, text);
// Allocate and init Element
- WidgetElement* gui_string = furi_alloc(sizeof(WidgetElement));
+ WidgetElement* gui_string = malloc(sizeof(WidgetElement));
gui_string->parent = NULL;
gui_string->input = NULL;
gui_string->draw = gui_text_box_draw;
diff --git a/applications/gui/scene_manager.c b/applications/gui/scene_manager.c
index a3aadb74..a8c40320 100755
--- a/applications/gui/scene_manager.c
+++ b/applications/gui/scene_manager.c
@@ -4,12 +4,12 @@
SceneManager* scene_manager_alloc(const SceneManagerHandlers* app_scene_handlers, void* context) {
furi_assert(context);
- SceneManager* scene_manager = furi_alloc(sizeof(SceneManager));
+ SceneManager* scene_manager = malloc(sizeof(SceneManager));
// Set SceneManager context and scene handlers
scene_manager->context = context;
scene_manager->scene_handlers = app_scene_handlers;
// Allocate all scenes
- scene_manager->scene = furi_alloc(sizeof(AppScene) * app_scene_handlers->scene_num);
+ scene_manager->scene = malloc(sizeof(AppScene) * app_scene_handlers->scene_num);
// Initialize ScaneManager array for navigation
SceneManagerIdStack_init(scene_manager->scene_id_stack);
@@ -48,9 +48,16 @@ bool scene_manager_handle_custom_event(SceneManager* scene_manager, uint32_t cus
.type = SceneManagerEventTypeCustom,
.event = custom_event,
};
- uint32_t scene_id = *SceneManagerIdStack_back(scene_manager->scene_id_stack);
- return scene_manager->scene_handlers->on_event_handlers[scene_id](
- scene_manager->context, event);
+
+ bool result = false;
+ if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) {
+ uint32_t* scene_id_p = SceneManagerIdStack_back(scene_manager->scene_id_stack);
+ uint32_t scene_id = *scene_id_p;
+ result = scene_manager->scene_handlers->on_event_handlers[scene_id](
+ scene_manager->context, event);
+ }
+
+ return result;
}
bool scene_manager_handle_back_event(SceneManager* scene_manager) {
@@ -59,9 +66,15 @@ bool scene_manager_handle_back_event(SceneManager* scene_manager) {
SceneManagerEvent event = {
.type = SceneManagerEventTypeBack,
};
- uint32_t scene_id = *SceneManagerIdStack_back(scene_manager->scene_id_stack);
- bool consumed =
- scene_manager->scene_handlers->on_event_handlers[scene_id](scene_manager->context, event);
+
+ bool consumed = false;
+ if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) {
+ uint32_t* scene_id_p = SceneManagerIdStack_back(scene_manager->scene_id_stack);
+ uint32_t scene_id = *scene_id_p;
+ consumed = scene_manager->scene_handlers->on_event_handlers[scene_id](
+ scene_manager->context, event);
+ }
+
if(!consumed) {
consumed = scene_manager_previous_scene(scene_manager);
}
@@ -74,8 +87,12 @@ void scene_manager_handle_tick_event(SceneManager* scene_manager) {
SceneManagerEvent event = {
.type = SceneManagerEventTypeTick,
};
- uint32_t scene_id = *SceneManagerIdStack_back(scene_manager->scene_id_stack);
- scene_manager->scene_handlers->on_event_handlers[scene_id](scene_manager->context, event);
+
+ if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) {
+ uint32_t* scene_id_p = SceneManagerIdStack_back(scene_manager->scene_id_stack);
+ uint32_t scene_id = *scene_id_p;
+ scene_manager->scene_handlers->on_event_handlers[scene_id](scene_manager->context, event);
+ }
}
void scene_manager_next_scene(SceneManager* scene_manager, uint32_t next_scene_id) {
@@ -83,7 +100,7 @@ void scene_manager_next_scene(SceneManager* scene_manager, uint32_t next_scene_i
furi_assert(next_scene_id < scene_manager->scene_handlers->scene_num);
// Check if it is not the first scene
- if(SceneManagerIdStack_size(scene_manager->scene_id_stack)) {
+ if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) {
uint32_t cur_scene_id = *SceneManagerIdStack_back(scene_manager->scene_id_stack);
scene_manager->scene_handlers->on_exit_handlers[cur_scene_id](scene_manager->context);
}
@@ -95,18 +112,22 @@ void scene_manager_next_scene(SceneManager* scene_manager, uint32_t next_scene_i
bool scene_manager_previous_scene(SceneManager* scene_manager) {
furi_assert(scene_manager);
- uint32_t cur_scene_id = 0;
- SceneManagerIdStack_pop_back(&cur_scene_id, scene_manager->scene_id_stack);
+ if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) {
+ uint32_t cur_scene_id = 0;
+ SceneManagerIdStack_pop_back(&cur_scene_id, scene_manager->scene_id_stack);
- // Handle exit from start scene separately
- if(SceneManagerIdStack_size(scene_manager->scene_id_stack) == 0) {
+ // Handle exit from start scene separately
+ if(SceneManagerIdStack_size(scene_manager->scene_id_stack) == 0) {
+ scene_manager->scene_handlers->on_exit_handlers[cur_scene_id](scene_manager->context);
+ return false;
+ }
+ uint32_t prev_scene_id = *SceneManagerIdStack_back(scene_manager->scene_id_stack);
scene_manager->scene_handlers->on_exit_handlers[cur_scene_id](scene_manager->context);
+ scene_manager->scene_handlers->on_enter_handlers[prev_scene_id](scene_manager->context);
+ return true;
+ } else {
return false;
}
- uint32_t prev_scene_id = *SceneManagerIdStack_back(scene_manager->scene_id_stack);
- scene_manager->scene_handlers->on_exit_handlers[cur_scene_id](scene_manager->context);
- scene_manager->scene_handlers->on_enter_handlers[prev_scene_id](scene_manager->context);
- return true;
}
bool scene_manager_search_and_switch_to_previous_scene(
@@ -114,48 +135,55 @@ bool scene_manager_search_and_switch_to_previous_scene(
uint32_t scene_id) {
furi_assert(scene_manager);
- uint32_t prev_scene_id = 0;
- uint32_t cur_scene_id = *SceneManagerIdStack_back(scene_manager->scene_id_stack);
- SceneManagerIdStack_it_t scene_it;
- SceneManagerIdStack_it_last(scene_it, scene_manager->scene_id_stack);
- // Search scene with given id in navigation stack
- bool scene_found = false;
- while(!scene_found) {
- SceneManagerIdStack_previous(scene_it);
- if(SceneManagerIdStack_end_p(scene_it)) {
- return false;
- }
- prev_scene_id = *SceneManagerIdStack_ref(scene_it);
- if(prev_scene_id == scene_id) {
- scene_found = true;
+ if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) {
+ uint32_t prev_scene_id = 0;
+ uint32_t cur_scene_id = *SceneManagerIdStack_back(scene_manager->scene_id_stack);
+ SceneManagerIdStack_it_t scene_it;
+ SceneManagerIdStack_it_last(scene_it, scene_manager->scene_id_stack);
+ // Search scene with given id in navigation stack
+ bool scene_found = false;
+ while(!scene_found) {
+ SceneManagerIdStack_previous(scene_it);
+ if(SceneManagerIdStack_end_p(scene_it)) {
+ return false;
+ }
+ prev_scene_id = *SceneManagerIdStack_ref(scene_it);
+ if(prev_scene_id == scene_id) {
+ scene_found = true;
+ }
}
- }
- // Remove all scene id from navigation stack
- SceneManagerIdStack_next(scene_it);
- SceneManagerIdStack_pop_until(scene_manager->scene_id_stack, scene_it);
+ // Remove all scene id from navigation stack
+ SceneManagerIdStack_next(scene_it);
+ SceneManagerIdStack_pop_until(scene_manager->scene_id_stack, scene_it);
- scene_manager->scene_handlers->on_exit_handlers[cur_scene_id](scene_manager->context);
- scene_manager->scene_handlers->on_enter_handlers[prev_scene_id](scene_manager->context);
+ scene_manager->scene_handlers->on_exit_handlers[cur_scene_id](scene_manager->context);
+ scene_manager->scene_handlers->on_enter_handlers[prev_scene_id](scene_manager->context);
- return true;
+ return true;
+ } else {
+ return false;
+ }
}
bool scene_manager_has_previous_scene(SceneManager* scene_manager, uint32_t scene_id) {
furi_assert(scene_manager);
bool scene_found = false;
- uint32_t prev_scene_id;
- SceneManagerIdStack_it_t scene_it;
- SceneManagerIdStack_it_last(scene_it, scene_manager->scene_id_stack);
-
- // Perform search in scene stack
- while(!scene_found) {
- SceneManagerIdStack_previous(scene_it);
- if(SceneManagerIdStack_end_p(scene_it)) {
- break;
- }
- prev_scene_id = *SceneManagerIdStack_ref(scene_it);
- if(prev_scene_id == scene_id) {
- scene_found = true;
+
+ if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) {
+ uint32_t prev_scene_id;
+ SceneManagerIdStack_it_t scene_it;
+ SceneManagerIdStack_it_last(scene_it, scene_manager->scene_id_stack);
+
+ // Perform search in scene stack
+ while(!scene_found) {
+ SceneManagerIdStack_previous(scene_it);
+ if(SceneManagerIdStack_end_p(scene_it)) {
+ break;
+ }
+ prev_scene_id = *SceneManagerIdStack_ref(scene_it);
+ if(prev_scene_id == scene_id) {
+ scene_found = true;
+ }
}
}
return scene_found;
@@ -167,25 +195,29 @@ bool scene_manager_search_and_switch_to_another_scene(
furi_assert(scene_manager);
furi_assert(scene_id < scene_manager->scene_handlers->scene_num);
- uint32_t cur_scene_id = *SceneManagerIdStack_back(scene_manager->scene_id_stack);
- SceneManagerIdStack_it_t scene_it;
- SceneManagerIdStack_it(scene_it, scene_manager->scene_id_stack);
- SceneManagerIdStack_next(scene_it);
- // Remove all scene id from navigation stack until first scene
- SceneManagerIdStack_pop_until(scene_manager->scene_id_stack, scene_it);
- // Add next scene
- SceneManagerIdStack_push_back(scene_manager->scene_id_stack, scene_id);
+ if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) {
+ uint32_t cur_scene_id = *SceneManagerIdStack_back(scene_manager->scene_id_stack);
+ SceneManagerIdStack_it_t scene_it;
+ SceneManagerIdStack_it(scene_it, scene_manager->scene_id_stack);
+ SceneManagerIdStack_next(scene_it);
+ // Remove all scene id from navigation stack until first scene
+ SceneManagerIdStack_pop_until(scene_manager->scene_id_stack, scene_it);
+ // Add next scene
+ SceneManagerIdStack_push_back(scene_manager->scene_id_stack, scene_id);
- scene_manager->scene_handlers->on_exit_handlers[cur_scene_id](scene_manager->context);
- scene_manager->scene_handlers->on_enter_handlers[scene_id](scene_manager->context);
+ scene_manager->scene_handlers->on_exit_handlers[cur_scene_id](scene_manager->context);
+ scene_manager->scene_handlers->on_enter_handlers[scene_id](scene_manager->context);
- return true;
+ return true;
+ } else {
+ return false;
+ }
}
void scene_manager_stop(SceneManager* scene_manager) {
furi_assert(scene_manager);
- if(SceneManagerIdStack_size(scene_manager->scene_id_stack)) {
+ if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) {
uint32_t cur_scene_id = *SceneManagerIdStack_back(scene_manager->scene_id_stack);
scene_manager->scene_handlers->on_exit_handlers[cur_scene_id](scene_manager->context);
}
diff --git a/applications/gui/view.c b/applications/gui/view.c
index c0420bd8..e9642d9b 100644
--- a/applications/gui/view.c
+++ b/applications/gui/view.c
@@ -1,7 +1,7 @@
#include "view_i.h"
View* view_alloc() {
- View* view = furi_alloc(sizeof(View));
+ View* view = malloc(sizeof(View));
view->orientation = ViewOrientationHorizontal;
return view;
}
@@ -78,12 +78,12 @@ void view_allocate_model(View* view, ViewModelType type, size_t size) {
furi_assert(view->model == NULL);
view->model_type = type;
if(view->model_type == ViewModelTypeLockFree) {
- view->model = furi_alloc(size);
+ view->model = malloc(size);
} else if(view->model_type == ViewModelTypeLocking) {
- ViewModelLocking* model = furi_alloc(sizeof(ViewModelLocking));
+ ViewModelLocking* model = malloc(sizeof(ViewModelLocking));
model->mutex = osMutexNew(NULL);
furi_check(model->mutex);
- model->data = furi_alloc(size);
+ model->data = malloc(size);
view->model = model;
} else {
furi_assert(false);
diff --git a/applications/gui/view_dispatcher.c b/applications/gui/view_dispatcher.c
index a32dde97..8bfb9e4e 100644
--- a/applications/gui/view_dispatcher.c
+++ b/applications/gui/view_dispatcher.c
@@ -3,7 +3,7 @@
#define TAG "ViewDispatcher"
ViewDispatcher* view_dispatcher_alloc() {
- ViewDispatcher* view_dispatcher = furi_alloc(sizeof(ViewDispatcher));
+ ViewDispatcher* view_dispatcher = malloc(sizeof(ViewDispatcher));
view_dispatcher->view_port = view_port_alloc();
view_port_draw_callback_set(
diff --git a/applications/gui/view_port.c b/applications/gui/view_port.c
index 66560bbc..8069a02e 100644
--- a/applications/gui/view_port.c
+++ b/applications/gui/view_port.c
@@ -35,7 +35,7 @@ static void view_port_setup_canvas_orientation(const ViewPort* view_port, Canvas
}
ViewPort* view_port_alloc() {
- ViewPort* view_port = furi_alloc(sizeof(ViewPort));
+ ViewPort* view_port = malloc(sizeof(ViewPort));
view_port->orientation = ViewPortOrientationHorizontal;
view_port->is_enabled = true;
return view_port;
diff --git a/applications/gui/view_stack.c b/applications/gui/view_stack.c
index d790b801..715b5486 100644
--- a/applications/gui/view_stack.c
+++ b/applications/gui/view_stack.c
@@ -62,7 +62,7 @@ static void view_stack_exit(void* context) {
}
ViewStack* view_stack_alloc(void) {
- ViewStack* view_stack = furi_alloc(sizeof(ViewStack));
+ ViewStack* view_stack = malloc(sizeof(ViewStack));
view_stack->view = view_alloc();
view_allocate_model(view_stack->view, ViewModelTypeLocking, sizeof(ViewStackModel));
diff --git a/applications/ibutton/ibutton_app.cpp b/applications/ibutton/ibutton_app.cpp
index 820cb74a..d69f0097 100644
--- a/applications/ibutton/ibutton_app.cpp
+++ b/applications/ibutton/ibutton_app.cpp
@@ -3,7 +3,7 @@
#include <callback-connector.h>
#include <m-string.h>
#include <toolbox/path.h>
-#include <flipper_file/flipper_file.h>
+#include <flipper_format/flipper_format.h>
const char* iButtonApp::app_folder = "/any/ibutton";
const char* iButtonApp::app_extension = ".ibtn";
@@ -191,7 +191,7 @@ bool iButtonApp::save_key(const char* key_name) {
// Create ibutton directory if necessary
make_app_folder();
- FlipperFile* file = flipper_file_alloc(storage);
+ FlipperFormat* file = flipper_format_file_alloc(storage);
string_t key_file_name;
bool result = false;
string_init(key_file_name);
@@ -207,29 +207,29 @@ bool iButtonApp::save_key(const char* key_name) {
string_printf(key_file_name, "%s/%s%s", app_folder, key.get_name(), app_extension);
// Open file for write
- if(!flipper_file_open_always(file, string_get_cstr(key_file_name))) break;
+ if(!flipper_format_file_open_always(file, string_get_cstr(key_file_name))) break;
// Write header
- if(!flipper_file_write_header_cstr(file, iButtonApp::app_filetype, 1)) break;
+ if(!flipper_format_write_header_cstr(file, iButtonApp::app_filetype, 1)) break;
// Write key type
- if(!flipper_file_write_comment_cstr(file, "Key type can be Cyfral, Dallas or Metakom"))
+ if(!flipper_format_write_comment_cstr(file, "Key type can be Cyfral, Dallas or Metakom"))
break;
const char* key_type = key.get_key_type_string_by_type(key.get_key_type());
- if(!flipper_file_write_string_cstr(file, "Key type", key_type)) break;
+ if(!flipper_format_write_string_cstr(file, "Key type", key_type)) break;
// Write data
- if(!flipper_file_write_comment_cstr(
+ if(!flipper_format_write_comment_cstr(
file, "Data size for Cyfral is 2, for Metakom is 4, for Dallas is 8"))
break;
- if(!flipper_file_write_hex(file, "Data", key.get_data(), key.get_type_data_size())) break;
+ if(!flipper_format_write_hex(file, "Data", key.get_data(), key.get_type_data_size()))
+ break;
result = true;
} while(false);
- flipper_file_close(file);
- flipper_file_free(file);
+ flipper_format_free(file);
string_clear(key_file_name);
@@ -241,28 +241,28 @@ bool iButtonApp::save_key(const char* key_name) {
}
bool iButtonApp::load_key_data(string_t key_path) {
- FlipperFile* file = flipper_file_alloc(storage);
+ FlipperFormat* file = flipper_format_file_alloc(storage);
bool result = false;
string_t data;
string_init(data);
do {
- if(!flipper_file_open_existing(file, string_get_cstr(key_path))) break;
+ if(!flipper_format_file_open_existing(file, string_get_cstr(key_path))) break;
// header
uint32_t version;
- if(!flipper_file_read_header(file, data, &version)) break;
+ if(!flipper_format_read_header(file, data, &version)) break;
if(string_cmp_str(data, iButtonApp::app_filetype) != 0) break;
if(version != 1) break;
// key type
iButtonKeyType type;
- if(!flipper_file_read_string(file, "Key type", data)) break;
+ if(!flipper_format_read_string(file, "Key type", data)) break;
if(!key.get_key_type_by_type_string(string_get_cstr(data), &type)) break;
// key data
uint8_t key_data[IBUTTON_KEY_DATA_SIZE] = {0};
- if(!flipper_file_read_hex(file, "Data", key_data, key.get_type_data_size_by_type(type)))
+ if(!flipper_format_read_hex(file, "Data", key_data, key.get_type_data_size_by_type(type)))
break;
key.set_type(type);
@@ -271,8 +271,7 @@ bool iButtonApp::load_key_data(string_t key_path) {
result = true;
} while(false);
- flipper_file_close(file);
- flipper_file_free(file);
+ flipper_format_free(file);
string_clear(data);
if(!result) {
diff --git a/applications/input/input.c b/applications/input/input.c
index 55a10113..46a9c369 100644
--- a/applications/input/input.c
+++ b/applications/input/input.c
@@ -66,7 +66,7 @@ const char* input_get_type_name(InputType type) {
}
int32_t input_srv() {
- input = furi_alloc(sizeof(Input));
+ input = malloc(sizeof(Input));
input->thread = osThreadGetId();
input->event_pubsub = furi_pubsub_alloc();
furi_record_create("input_events", input->event_pubsub);
@@ -78,7 +78,7 @@ int32_t input_srv() {
}
#endif
- input->pin_states = furi_alloc(input_pins_count * sizeof(InputPinState));
+ input->pin_states = malloc(input_pins_count * sizeof(InputPinState));
for(size_t i = 0; i < input_pins_count; i++) {
GpioPin gpio = {(GPIO_TypeDef*)input_pins[i].port, (uint16_t)input_pins[i].pin};
diff --git a/applications/irda/cli/irda_cli.cpp b/applications/irda/cli/irda_cli.cpp
index 3a4121df..e8a61dc3 100644
--- a/applications/irda/cli/irda_cli.cpp
+++ b/applications/irda/cli/irda_cli.cpp
@@ -145,7 +145,7 @@ static void irda_cli_start_ir_tx(Cli* cli, string_t args) {
uint32_t frequency;
float duty_cycle;
uint32_t timings_cnt = MAX_TIMINGS_AMOUNT;
- uint32_t* timings = (uint32_t*)furi_alloc(sizeof(uint32_t) * timings_cnt);
+ uint32_t* timings = (uint32_t*)malloc(sizeof(uint32_t) * timings_cnt);
if(parse_message(str, &message)) {
irda_send(&message, 1);
diff --git a/applications/irda/helpers/irda_parser.cpp b/applications/irda/helpers/irda_parser.cpp
index be0b17aa..a23a9b6d 100644
--- a/applications/irda/helpers/irda_parser.cpp
+++ b/applications/irda/helpers/irda_parser.cpp
@@ -4,37 +4,42 @@
#include "irda/helpers/irda_parser.h"
#include "irda_worker.h"
#include "m-string.h"
-#include <flipper_file.h>
+#include <flipper_format/flipper_format.h>
#include <memory>
#include <string>
#include <furi_hal_irda.h>
#define TAG "IrdaParser"
-bool irda_parser_save_signal(FlipperFile* ff, const IrdaAppSignal& signal, const std::string& name) {
+bool irda_parser_save_signal(
+ FlipperFormat* ff,
+ const IrdaAppSignal& signal,
+ const std::string& name) {
furi_assert(ff);
furi_assert(!name.empty());
bool result = false;
do {
- if(!flipper_file_write_comment_cstr(ff, "")) break;
- if(!flipper_file_write_string_cstr(ff, "name", name.c_str())) break;
+ if(!flipper_format_write_comment_cstr(ff, "")) break;
+ if(!flipper_format_write_string_cstr(ff, "name", name.c_str())) break;
if(signal.is_raw()) {
furi_assert(signal.get_raw_signal().timings_cnt <= MAX_TIMINGS_AMOUNT);
auto raw_signal = signal.get_raw_signal();
- if(!flipper_file_write_string_cstr(ff, "type", "raw")) break;
- if(!flipper_file_write_uint32(ff, "frequency", &raw_signal.frequency, 1)) break;
- if(!flipper_file_write_float(ff, "duty_cycle", &raw_signal.duty_cycle, 1)) break;
- if(!flipper_file_write_uint32(ff, "data", raw_signal.timings, raw_signal.timings_cnt))
+ if(!flipper_format_write_string_cstr(ff, "type", "raw")) break;
+ if(!flipper_format_write_uint32(ff, "frequency", &raw_signal.frequency, 1)) break;
+ if(!flipper_format_write_float(ff, "duty_cycle", &raw_signal.duty_cycle, 1)) break;
+ if(!flipper_format_write_uint32(ff, "data", raw_signal.timings, raw_signal.timings_cnt))
break;
} else {
auto parsed_signal = signal.get_message();
const char* protocol_name = irda_get_protocol_name(parsed_signal.protocol);
- if(!flipper_file_write_string_cstr(ff, "type", "parsed")) break;
- if(!flipper_file_write_string_cstr(ff, "protocol", protocol_name)) break;
- if(!flipper_file_write_hex(ff, "address", (uint8_t*)&parsed_signal.address, 4)) break;
- if(!flipper_file_write_hex(ff, "command", (uint8_t*)&parsed_signal.command, 4)) break;
+ if(!flipper_format_write_string_cstr(ff, "type", "parsed")) break;
+ if(!flipper_format_write_string_cstr(ff, "protocol", protocol_name)) break;
+ if(!flipper_format_write_hex(ff, "address", (uint8_t*)&parsed_signal.address, 4))
+ break;
+ if(!flipper_format_write_hex(ff, "command", (uint8_t*)&parsed_signal.command, 4))
+ break;
}
result = true;
} while(0);
@@ -42,7 +47,7 @@ bool irda_parser_save_signal(FlipperFile* ff, const IrdaAppSignal& signal, const
return result;
}
-bool irda_parser_read_signal(FlipperFile* ff, IrdaAppSignal& signal, std::string& name) {
+bool irda_parser_read_signal(FlipperFormat* ff, IrdaAppSignal& signal, std::string& name) {
furi_assert(ff);
bool result = false;
@@ -50,31 +55,31 @@ bool irda_parser_read_signal(FlipperFile* ff, IrdaAppSignal& signal, std::string
string_init(read_string);
do {
- if(!flipper_file_read_string(ff, "name", read_string)) break;
+ if(!flipper_format_read_string(ff, "name", read_string)) break;
name = string_get_cstr(read_string);
- if(!flipper_file_read_string(ff, "type", read_string)) break;
+ if(!flipper_format_read_string(ff, "type", read_string)) break;
if(!string_cmp_str(read_string, "raw")) {
uint32_t* timings = nullptr;
uint32_t timings_cnt = 0;
uint32_t frequency = 0;
float duty_cycle = 0;
- if(!flipper_file_read_uint32(ff, "frequency", &frequency, 1)) break;
- if(!flipper_file_read_float(ff, "duty_cycle", &duty_cycle, 1)) break;
- if(!flipper_file_get_value_count(ff, "data", &timings_cnt)) break;
+ if(!flipper_format_read_uint32(ff, "frequency", &frequency, 1)) break;
+ if(!flipper_format_read_float(ff, "duty_cycle", &duty_cycle, 1)) break;
+ if(!flipper_format_get_value_count(ff, "data", &timings_cnt)) break;
if(timings_cnt > MAX_TIMINGS_AMOUNT) break;
- timings = (uint32_t*)furi_alloc(sizeof(uint32_t) * timings_cnt);
- if(flipper_file_read_uint32(ff, "data", timings, timings_cnt)) {
+ timings = (uint32_t*)malloc(sizeof(uint32_t) * timings_cnt);
+ if(flipper_format_read_uint32(ff, "data", timings, timings_cnt)) {
signal.set_raw_signal(timings, timings_cnt, frequency, duty_cycle);
result = true;
}
free(timings);
} else if(!string_cmp_str(read_string, "parsed")) {
IrdaMessage parsed_signal;
- if(!flipper_file_read_string(ff, "protocol", read_string)) break;
+ if(!flipper_format_read_string(ff, "protocol", read_string)) break;
parsed_signal.protocol = irda_get_protocol_by_name(string_get_cstr(read_string));
- if(!flipper_file_read_hex(ff, "address", (uint8_t*)&parsed_signal.address, 4)) break;
- if(!flipper_file_read_hex(ff, "command", (uint8_t*)&parsed_signal.command, 4)) break;
+ if(!flipper_format_read_hex(ff, "address", (uint8_t*)&parsed_signal.address, 4)) break;
+ if(!flipper_format_read_hex(ff, "command", (uint8_t*)&parsed_signal.command, 4)) break;
if(!irda_parser_is_parsed_signal_valid(&parsed_signal)) break;
signal.set_message(&parsed_signal);
result = true;
diff --git a/applications/irda/helpers/irda_parser.h b/applications/irda/helpers/irda_parser.h
index bc68825c..d8065607 100644
--- a/applications/irda/helpers/irda_parser.h
+++ b/applications/irda/helpers/irda_parser.h
@@ -1,10 +1,13 @@
#pragma once
#include "../irda_app_signal.h"
-#include <flipper_file.h>
+#include <flipper_format/flipper_format.h>
#include <string>
-bool irda_parser_save_signal(FlipperFile* ff, const IrdaAppSignal& signal, const std::string& name);
-bool irda_parser_read_signal(FlipperFile* ff, IrdaAppSignal& signal, std::string& name);
+bool irda_parser_save_signal(
+ FlipperFormat* ff,
+ const IrdaAppSignal& signal,
+ const std::string& name);
+bool irda_parser_read_signal(FlipperFormat* ff, IrdaAppSignal& signal, std::string& name);
bool irda_parser_is_parsed_signal_valid(const IrdaMessage* signal);
bool irda_parser_is_raw_signal_valid(uint32_t frequency, float duty_cycle, uint32_t timings_cnt);
diff --git a/applications/irda/irda_app_brute_force.cpp b/applications/irda/irda_app_brute_force.cpp
index 43f91150..8d7d684d 100644
--- a/applications/irda/irda_app_brute_force.cpp
+++ b/applications/irda/irda_app_brute_force.cpp
@@ -16,15 +16,15 @@ bool IrdaAppBruteForce::calculate_messages() {
bool result = false;
Storage* storage = static_cast<Storage*>(furi_record_open("storage"));
- FlipperFile* ff = flipper_file_alloc(storage);
- result = flipper_file_open_existing(ff, universal_db_filename);
+ FlipperFormat* ff = flipper_format_file_alloc(storage);
+ result = flipper_format_file_open_existing(ff, universal_db_filename);
if(result) {
IrdaAppSignal signal;
string_t signal_name;
string_init(signal_name);
- while(flipper_file_read_string(ff, "name", signal_name)) {
+ while(flipper_format_read_string(ff, "name", signal_name)) {
auto element = records.find(string_get_cstr(signal_name));
if(element != records.cend()) {
++element->second.amount;
@@ -33,8 +33,7 @@ bool IrdaAppBruteForce::calculate_messages() {
string_clear(signal_name);
}
- flipper_file_close(ff);
- flipper_file_free(ff);
+ flipper_format_free(ff);
furi_record_close("storage");
return result;
}
@@ -45,8 +44,7 @@ void IrdaAppBruteForce::stop_bruteforce() {
if(current_record.size()) {
furi_assert(ff);
current_record.clear();
- flipper_file_close(ff);
- flipper_file_free(ff);
+ flipper_format_free(ff);
furi_record_close("storage");
}
}
@@ -84,11 +82,10 @@ bool IrdaAppBruteForce::start_bruteforce(int index, int& record_amount) {
if(record_amount) {
Storage* storage = static_cast<Storage*>(furi_record_open("storage"));
- ff = flipper_file_alloc(storage);
- result = flipper_file_open_existing(ff, universal_db_filename);
+ ff = flipper_format_file_alloc(storage);
+ result = flipper_format_file_open_existing(ff, universal_db_filename);
if(!result) {
- flipper_file_close(ff);
- flipper_file_free(ff);
+ flipper_format_free(ff);
furi_record_close("storage");
}
}
diff --git a/applications/irda/irda_app_brute_force.h b/applications/irda/irda_app_brute_force.h
index 439eba4f..97d78dc6 100644
--- a/applications/irda/irda_app_brute_force.h
+++ b/applications/irda/irda_app_brute_force.h
@@ -2,12 +2,12 @@
#include <unordered_map>
#include <memory>
-#include <flipper_file.h>
+#include <flipper_format/flipper_format.h>
class IrdaAppBruteForce {
const char* universal_db_filename;
std::string current_record;
- FlipperFile* ff;
+ FlipperFormat* ff;
typedef struct {
int index;
diff --git a/applications/irda/irda_app_remote_manager.cpp b/applications/irda/irda_app_remote_manager.cpp
index 8b88d37d..d2081b42 100644
--- a/applications/irda/irda_app_remote_manager.cpp
+++ b/applications/irda/irda_app_remote_manager.cpp
@@ -1,5 +1,5 @@
#include <file_worker_cpp.h>
-#include <flipper_file.h>
+#include <flipper_format/flipper_format.h>
#include "irda_app_remote_manager.h"
#include "irda/helpers/irda_parser.h"
#include "irda/irda_app_signal.h"
@@ -169,12 +169,12 @@ bool IrdaAppRemoteManager::store(void) {
if(!file_worker.mkdir(IrdaApp::irda_directory)) return false;
Storage* storage = static_cast<Storage*>(furi_record_open("storage"));
- FlipperFile* ff = flipper_file_alloc(storage);
+ FlipperFormat* ff = flipper_format_file_alloc(storage);
FURI_LOG_I("RemoteManager", "store file: \'%s\'", make_full_name(remote->name).c_str());
- result = flipper_file_open_always(ff, make_full_name(remote->name).c_str());
+ result = flipper_format_file_open_always(ff, make_full_name(remote->name).c_str());
if(result) {
- result = flipper_file_write_header_cstr(ff, "IR signals file", 1);
+ result = flipper_format_write_header_cstr(ff, "IR signals file", 1);
}
if(result) {
for(const auto& button : remote->buttons) {
@@ -185,8 +185,7 @@ bool IrdaAppRemoteManager::store(void) {
}
}
- flipper_file_close(ff);
- flipper_file_free(ff);
+ flipper_format_free(ff);
furi_record_close("storage");
return result;
}
@@ -194,15 +193,15 @@ bool IrdaAppRemoteManager::store(void) {
bool IrdaAppRemoteManager::load(const std::string& remote_name) {
bool result = false;
Storage* storage = static_cast<Storage*>(furi_record_open("storage"));
- FlipperFile* ff = flipper_file_alloc(storage);
+ FlipperFormat* ff = flipper_format_file_alloc(storage);
FURI_LOG_I("RemoteManager", "load file: \'%s\'", make_full_name(remote_name).c_str());
- result = flipper_file_open_existing(ff, make_full_name(remote_name).c_str());
+ result = flipper_format_file_open_existing(ff, make_full_name(remote_name).c_str());
if(result) {
string_t header;
string_init(header);
uint32_t version;
- result = flipper_file_read_header(ff, header, &version);
+ result = flipper_format_read_header(ff, header, &version);
if(result) {
result = !string_cmp_str(header, "IR signals file") && (version == 1);
}
@@ -217,8 +216,7 @@ bool IrdaAppRemoteManager::load(const std::string& remote_name) {
}
}
- flipper_file_close(ff);
- flipper_file_free(ff);
+ flipper_format_free(ff);
furi_record_close("storage");
return result;
}
diff --git a/applications/irda/view/irda_app_brut_view.c b/applications/irda/view/irda_app_brut_view.c
index 4b2db642..91429a35 100644
--- a/applications/irda/view/irda_app_brut_view.c
+++ b/applications/irda/view/irda_app_brut_view.c
@@ -76,7 +76,7 @@ void popup_brut_set_progress_max(IrdaAppPopupBrut* popup_brut, uint16_t progress
}
IrdaAppPopupBrut* popup_brut_alloc(void) {
- return (IrdaAppPopupBrut*)furi_alloc(sizeof(IrdaAppPopupBrut));
+ return (IrdaAppPopupBrut*)malloc(sizeof(IrdaAppPopupBrut));
}
void popup_brut_free(IrdaAppPopupBrut* popup_brut) {
diff --git a/applications/irda_monitor/irda_monitor.c b/applications/irda_monitor/irda_monitor.c
index d2032e38..5325d192 100644
--- a/applications/irda_monitor/irda_monitor.c
+++ b/applications/irda_monitor/irda_monitor.c
@@ -99,7 +99,7 @@ static void signal_received_callback(void* context, IrdaWorkerSignal* received_s
int32_t irda_monitor_app(void* p) {
(void)p;
- IrdaMonitor* irda_monitor = furi_alloc(sizeof(IrdaMonitor));
+ IrdaMonitor* irda_monitor = malloc(sizeof(IrdaMonitor));
irda_monitor->display_text[0] = 0;
irda_monitor->event_queue = osMessageQueueNew(1, sizeof(InputEvent), NULL);
irda_monitor->view_port = view_port_alloc();
diff --git a/applications/lfrfid/lfrfid_app.cpp b/applications/lfrfid/lfrfid_app.cpp
index 870952d5..fecf15a7 100644
--- a/applications/lfrfid/lfrfid_app.cpp
+++ b/applications/lfrfid/lfrfid_app.cpp
@@ -17,7 +17,7 @@
#include "scene/lfrfid_app_scene_delete_success.h"
#include <toolbox/path.h>
-#include <flipper_file/flipper_file.h>
+#include <flipper_format/flipper_format.h>
const char* LfRfidApp::app_folder = "/any/lfrfid";
const char* LfRfidApp::app_extension = ".rfid";
@@ -119,17 +119,17 @@ bool LfRfidApp::delete_key(RfidKey* key) {
}
bool LfRfidApp::load_key_data(const char* path, RfidKey* key) {
- FlipperFile* file = flipper_file_alloc(storage);
+ FlipperFormat* file = flipper_format_file_alloc(storage);
bool result = false;
string_t str_result;
string_init(str_result);
do {
- if(!flipper_file_open_existing(file, path)) break;
+ if(!flipper_format_file_open_existing(file, path)) break;
// header
uint32_t version;
- if(!flipper_file_read_header(file, str_result, &version)) break;
+ if(!flipper_format_read_header(file, str_result, &version)) break;
if(string_cmp_str(str_result, app_filetype) != 0) break;
if(version != 1) break;
@@ -137,13 +137,14 @@ bool LfRfidApp::load_key_data(const char* path, RfidKey* key) {
LfrfidKeyType type;
RfidKey loaded_key;
- if(!flipper_file_read_string(file, "Key type", str_result)) break;
+ if(!flipper_format_read_string(file, "Key type", str_result)) break;
if(!lfrfid_key_get_string_type(string_get_cstr(str_result), &type)) break;
loaded_key.set_type(type);
// key data
uint8_t key_data[loaded_key.get_type_data_count()] = {};
- if(!flipper_file_read_hex(file, "Data", key_data, loaded_key.get_type_data_count())) break;
+ if(!flipper_format_read_hex(file, "Data", key_data, loaded_key.get_type_data_count()))
+ break;
loaded_key.set_data(key_data, loaded_key.get_type_data_count());
path_extract_filename_no_ext(path, str_result);
@@ -153,8 +154,7 @@ bool LfRfidApp::load_key_data(const char* path, RfidKey* key) {
result = true;
} while(0);
- flipper_file_close(file);
- flipper_file_free(file);
+ flipper_format_free(file);
string_clear(str_result);
if(!result) {
@@ -165,27 +165,26 @@ bool LfRfidApp::load_key_data(const char* path, RfidKey* key) {
}
bool LfRfidApp::save_key_data(const char* path, RfidKey* key) {
- FlipperFile* file = flipper_file_alloc(storage);
+ FlipperFormat* file = flipper_format_file_alloc(storage);
bool result = false;
do {
- if(!flipper_file_open_always(file, path)) break;
- if(!flipper_file_write_header_cstr(file, app_filetype, 1)) break;
- if(!flipper_file_write_comment_cstr(file, "Key type can be EM4100, H10301 or I40134"))
+ if(!flipper_format_file_open_always(file, path)) break;
+ if(!flipper_format_write_header_cstr(file, app_filetype, 1)) break;
+ if(!flipper_format_write_comment_cstr(file, "Key type can be EM4100, H10301 or I40134"))
break;
- if(!flipper_file_write_string_cstr(
+ if(!flipper_format_write_string_cstr(
file, "Key type", lfrfid_key_get_type_string(key->get_type())))
break;
- if(!flipper_file_write_comment_cstr(
+ if(!flipper_format_write_comment_cstr(
file, "Data size for EM4100 is 5, for H10301 is 3, for I40134 is 3"))
break;
- if(!flipper_file_write_hex(file, "Data", key->get_data(), key->get_type_data_count()))
+ if(!flipper_format_write_hex(file, "Data", key->get_data(), key->get_type_data_count()))
break;
result = true;
} while(0);
- flipper_file_close(file);
- flipper_file_free(file);
+ flipper_format_free(file);
if(!result) {
dialog_message_show_storage_error(dialogs, "Cannot save\nkey file");
diff --git a/applications/loader/loader.c b/applications/loader/loader.c
index b8f67a59..552b46f2 100644
--- a/applications/loader/loader.c
+++ b/applications/loader/loader.c
@@ -278,7 +278,7 @@ static uint32_t loader_back_to_primary_menu(void* context) {
}
static Loader* loader_alloc() {
- Loader* instance = furi_alloc(sizeof(Loader));
+ Loader* instance = malloc(sizeof(Loader));
instance->application_thread = furi_thread_alloc();
furi_thread_enable_heap_trace(instance->application_thread);
diff --git a/applications/nfc/helpers/nfc_emv_parser.c b/applications/nfc/helpers/nfc_emv_parser.c
index 4012ff45..2e060999 100755
--- a/applications/nfc/helpers/nfc_emv_parser.c
+++ b/applications/nfc/helpers/nfc_emv_parser.c
@@ -1,5 +1,5 @@
#include "nfc_emv_parser.h"
-#include <lib/flipper_file/flipper_file.h>
+#include <flipper_format/flipper_format.h>
static const char* nfc_resources_header = "Flipper EMV resources";
static const uint32_t nfc_resources_file_version = 1;
@@ -10,25 +10,25 @@ static bool nfc_emv_parser_search_data(
string_t key,
string_t data) {
bool parsed = false;
- FlipperFile* file = flipper_file_alloc(storage);
+ FlipperFormat* file = flipper_format_file_alloc(storage);
string_t temp_str;
string_init(temp_str);
do {
// Open file
- if(!flipper_file_open_existing(file, file_name)) break;
+ if(!flipper_format_file_open_existing(file, file_name)) break;
// Read file header and version
uint32_t version = 0;
- if(!flipper_file_read_header(file, temp_str, &version)) break;
+ if(!flipper_format_read_header(file, temp_str, &version)) break;
if(string_cmp_str(temp_str, nfc_resources_header) ||
(version != nfc_resources_file_version))
break;
- if(!flipper_file_read_string(file, string_get_cstr(key), data)) break;
+ if(!flipper_format_read_string(file, string_get_cstr(key), data)) break;
parsed = true;
} while(false);
string_clear(temp_str);
- flipper_file_free(file);
+ flipper_format_free(file);
return parsed;
}
diff --git a/applications/nfc/nfc.c b/applications/nfc/nfc.c
index acf4c7cf..5b3453d8 100755
--- a/applications/nfc/nfc.c
+++ b/applications/nfc/nfc.c
@@ -20,7 +20,7 @@ void nfc_tick_event_callback(void* context) {
}
Nfc* nfc_alloc() {
- Nfc* nfc = furi_alloc(sizeof(Nfc));
+ Nfc* nfc = malloc(sizeof(Nfc));
nfc->worker = nfc_worker_alloc();
nfc->view_dispatcher = view_dispatcher_alloc();
diff --git a/applications/nfc/nfc_device.c b/applications/nfc/nfc_device.c
index d6996b3f..1f4c35cc 100755
--- a/applications/nfc/nfc_device.c
+++ b/applications/nfc/nfc_device.c
@@ -1,14 +1,14 @@
#include "nfc_device.h"
#include "nfc_types.h"
-#include <lib/toolbox/path.h>
-#include <lib/flipper_file/flipper_file.h>
+#include <toolbox/path.h>
+#include <flipper_format/flipper_format.h>
static const char* nfc_file_header = "Flipper NFC device";
static const uint32_t nfc_file_version = 2;
NfcDevice* nfc_device_alloc() {
- NfcDevice* nfc_dev = furi_alloc(sizeof(NfcDevice));
+ NfcDevice* nfc_dev = malloc(sizeof(NfcDevice));
nfc_dev->storage = furi_record_open("storage");
nfc_dev->dialogs = furi_record_open("dialogs");
return nfc_dev;
@@ -56,7 +56,7 @@ bool nfc_device_parse_format_string(NfcDevice* dev, string_t format_string) {
return false;
}
-static bool nfc_device_save_mifare_ul_data(FlipperFile* file, NfcDevice* dev) {
+static bool nfc_device_save_mifare_ul_data(FlipperFormat* file, NfcDevice* dev) {
bool saved = false;
MifareUlData* data = &dev->dev_data.mf_ul_data;
string_t temp_str;
@@ -64,22 +64,23 @@ static bool nfc_device_save_mifare_ul_data(FlipperFile* file, NfcDevice* dev) {
// Save Mifare Ultralight specific data
do {
- if(!flipper_file_write_comment_cstr(file, "Mifare Ultralight specific data")) break;
- if(!flipper_file_write_hex(file, "Signature", data->signature, sizeof(data->signature)))
+ if(!flipper_format_write_comment_cstr(file, "Mifare Ultralight specific data")) break;
+ if(!flipper_format_write_hex(file, "Signature", data->signature, sizeof(data->signature)))
break;
- if(!flipper_file_write_hex(
+ if(!flipper_format_write_hex(
file, "Mifare version", (uint8_t*)&data->version, sizeof(data->version)))
break;
// Write conters and tearing flags data
bool counters_saved = true;
for(uint8_t i = 0; i < 3; i++) {
string_printf(temp_str, "Counter %d", i);
- if(!flipper_file_write_uint32(file, string_get_cstr(temp_str), &data->counter[i], 1)) {
+ if(!flipper_format_write_uint32(
+ file, string_get_cstr(temp_str), &data->counter[i], 1)) {
counters_saved = false;
break;
}
string_printf(temp_str, "Tearing %d", i);
- if(!flipper_file_write_hex(file, string_get_cstr(temp_str), &data->tearing[i], 1)) {
+ if(!flipper_format_write_hex(file, string_get_cstr(temp_str), &data->tearing[i], 1)) {
counters_saved = false;
break;
}
@@ -87,11 +88,11 @@ static bool nfc_device_save_mifare_ul_data(FlipperFile* file, NfcDevice* dev) {
if(!counters_saved) break;
// Write pages data
uint32_t pages_total = data->data_size / 4;
- if(!flipper_file_write_uint32(file, "Pages total", &pages_total, 1)) break;
+ if(!flipper_format_write_uint32(file, "Pages total", &pages_total, 1)) break;
bool pages_saved = true;
for(uint16_t i = 0; i < data->data_size; i += 4) {
string_printf(temp_str, "Page %d", i / 4);
- if(!flipper_file_write_hex(file, string_get_cstr(temp_str), &data->data[i], 4)) {
+ if(!flipper_format_write_hex(file, string_get_cstr(temp_str), &data->data[i], 4)) {
pages_saved = false;
break;
}
@@ -104,7 +105,7 @@ static bool nfc_device_save_mifare_ul_data(FlipperFile* file, NfcDevice* dev) {
return saved;
}
-bool nfc_device_load_mifare_ul_data(FlipperFile* file, NfcDevice* dev) {
+bool nfc_device_load_mifare_ul_data(FlipperFormat* file, NfcDevice* dev) {
bool parsed = false;
MifareUlData* data = &dev->dev_data.mf_ul_data;
string_t temp_str;
@@ -112,22 +113,22 @@ bool nfc_device_load_mifare_ul_data(FlipperFile* file, NfcDevice* dev) {
do {
// Read signature
- if(!flipper_file_read_hex(file, "Signature", data->signature, sizeof(data->signature)))
+ if(!flipper_format_read_hex(file, "Signature", data->signature, sizeof(data->signature)))
break;
// Read Mifare version
- if(!flipper_file_read_hex(
+ if(!flipper_format_read_hex(
file, "Mifare version", (uint8_t*)&data->version, sizeof(data->version)))
break;
// Read counters and tearing flags
bool counters_parsed = true;
for(uint8_t i = 0; i < 3; i++) {
string_printf(temp_str, "Counter %d", i);
- if(!flipper_file_read_uint32(file, string_get_cstr(temp_str), &data->counter[i], 1)) {
+ if(!flipper_format_read_uint32(file, string_get_cstr(temp_str), &data->counter[i], 1)) {
counters_parsed = false;
break;
}
string_printf(temp_str, "Tearing %d", i);
- if(!flipper_file_read_hex(file, string_get_cstr(temp_str), &data->tearing[i], 1)) {
+ if(!flipper_format_read_hex(file, string_get_cstr(temp_str), &data->tearing[i], 1)) {
counters_parsed = false;
break;
}
@@ -135,12 +136,12 @@ bool nfc_device_load_mifare_ul_data(FlipperFile* file, NfcDevice* dev) {
if(!counters_parsed) break;
// Read pages
uint32_t pages = 0;
- if(!flipper_file_read_uint32(file, "Pages total", &pages, 1)) break;
+ if(!flipper_format_read_uint32(file, "Pages total", &pages, 1)) break;
data->data_size = pages * 4;
bool pages_parsed = true;
for(uint16_t i = 0; i < pages; i++) {
string_printf(temp_str, "Page %d", i);
- if(!flipper_file_read_hex(file, string_get_cstr(temp_str), &data->data[i * 4], 4)) {
+ if(!flipper_format_read_hex(file, string_get_cstr(temp_str), &data->data[i * 4], 4)) {
pages_parsed = false;
break;
}
@@ -153,28 +154,28 @@ bool nfc_device_load_mifare_ul_data(FlipperFile* file, NfcDevice* dev) {
return parsed;
}
-static bool nfc_device_save_bank_card_data(FlipperFile* file, NfcDevice* dev) {
+static bool nfc_device_save_bank_card_data(FlipperFormat* file, NfcDevice* dev) {
bool saved = false;
NfcEmvData* data = &dev->dev_data.emv_data;
uint32_t data_temp = 0;
do {
// Write Bank card specific data
- if(!flipper_file_write_comment_cstr(file, "Bank card specific data")) break;
- if(!flipper_file_write_hex(file, "AID", data->aid, data->aid_len)) break;
- if(!flipper_file_write_string_cstr(file, "Name", data->name)) break;
- if(!flipper_file_write_hex(file, "Number", data->number, data->number_len)) break;
+ if(!flipper_format_write_comment_cstr(file, "Bank card specific data")) break;
+ if(!flipper_format_write_hex(file, "AID", data->aid, data->aid_len)) break;
+ if(!flipper_format_write_string_cstr(file, "Name", data->name)) break;
+ if(!flipper_format_write_hex(file, "Number", data->number, data->number_len)) break;
if(data->exp_mon) {
uint8_t exp_data[2] = {data->exp_mon, data->exp_year};
- if(!flipper_file_write_hex(file, "Exp data", exp_data, sizeof(exp_data))) break;
+ if(!flipper_format_write_hex(file, "Exp data", exp_data, sizeof(exp_data))) break;
}
if(data->country_code) {
data_temp = data->country_code;
- if(!flipper_file_write_uint32(file, "Country code", &data_temp, 1)) break;
+ if(!flipper_format_write_uint32(file, "Country code", &data_temp, 1)) break;
}
if(data->currency_code) {
data_temp = data->currency_code;
- if(!flipper_file_write_uint32(file, "Currency code", &data_temp, 1)) break;
+ if(!flipper_format_write_uint32(file, "Currency code", &data_temp, 1)) break;
}
saved = true;
} while(false);
@@ -182,7 +183,7 @@ static bool nfc_device_save_bank_card_data(FlipperFile* file, NfcDevice* dev) {
return saved;
}
-bool nfc_device_load_bank_card_data(FlipperFile* file, NfcDevice* dev) {
+bool nfc_device_load_bank_card_data(FlipperFormat* file, NfcDevice* dev) {
bool parsed = false;
NfcEmvData* data = &dev->dev_data.emv_data;
memset(data, 0, sizeof(NfcEmvData));
@@ -192,25 +193,25 @@ bool nfc_device_load_bank_card_data(FlipperFile* file, NfcDevice* dev) {
do {
// Load essential data
- if(!flipper_file_get_value_count(file, "AID", &data_cnt)) break;
+ if(!flipper_format_get_value_count(file, "AID", &data_cnt)) break;
data->aid_len = data_cnt;
- if(!flipper_file_read_hex(file, "AID", data->aid, data->aid_len)) break;
- if(!flipper_file_read_string(file, "Name", temp_str)) break;
+ if(!flipper_format_read_hex(file, "AID", data->aid, data->aid_len)) break;
+ if(!flipper_format_read_string(file, "Name", temp_str)) break;
strlcpy(data->name, string_get_cstr(temp_str), sizeof(data->name));
- if(!flipper_file_get_value_count(file, "Number", &data_cnt)) break;
+ if(!flipper_format_get_value_count(file, "Number", &data_cnt)) break;
data->number_len = data_cnt;
- if(!flipper_file_read_hex(file, "Number", data->number, data->number_len)) break;
+ if(!flipper_format_read_hex(file, "Number", data->number, data->number_len)) break;
parsed = true;
// Load optional data
uint8_t exp_data[2] = {};
- if(flipper_file_read_hex(file, "Exp data", exp_data, 2)) {
+ if(flipper_format_read_hex(file, "Exp data", exp_data, 2)) {
data->exp_mon = exp_data[0];
data->exp_year = exp_data[1];
}
- if(flipper_file_read_uint32(file, "Country code", &data_cnt, 1)) {
+ if(flipper_format_read_uint32(file, "Country code", &data_cnt, 1)) {
data->country_code = data_cnt;
}
- if(flipper_file_read_uint32(file, "Currency code", &data_cnt, 1)) {
+ if(flipper_format_read_uint32(file, "Currency code", &data_cnt, 1)) {
data->currency_code = data_cnt;
}
} while(false);
@@ -233,7 +234,7 @@ static bool nfc_device_save_file(
furi_assert(dev);
bool saved = false;
- FlipperFile* file = flipper_file_alloc(dev->storage);
+ FlipperFormat* file = flipper_format_file_alloc(dev->storage);
NfcDeviceCommonData* data = &dev->dev_data.nfc_data;
string_t temp_str;
string_init(temp_str);
@@ -244,21 +245,21 @@ static bool nfc_device_save_file(
// First remove nfc device file if it was saved
string_printf(temp_str, "%s/%s%s", folder, dev_name, extension);
// Open file
- if(!flipper_file_open_always(file, string_get_cstr(temp_str))) break;
+ if(!flipper_format_file_open_always(file, string_get_cstr(temp_str))) break;
// Write header
- if(!flipper_file_write_header_cstr(file, nfc_file_header, nfc_file_version)) break;
+ if(!flipper_format_write_header_cstr(file, nfc_file_header, nfc_file_version)) break;
// Write nfc device type
- if(!flipper_file_write_comment_cstr(
+ if(!flipper_format_write_comment_cstr(
file, "Nfc device type can be UID, Mifare Ultralight, Bank card"))
break;
nfc_device_prepare_format_string(dev, temp_str);
- if(!flipper_file_write_string(file, "Device type", temp_str)) break;
+ if(!flipper_format_write_string(file, "Device type", temp_str)) break;
// Write UID, ATQA, SAK
- if(!flipper_file_write_comment_cstr(file, "UID, ATQA and SAK are common for all formats"))
+ if(!flipper_format_write_comment_cstr(file, "UID, ATQA and SAK are common for all formats"))
break;
- if(!flipper_file_write_hex(file, "UID", data->uid, data->uid_len)) break;
- if(!flipper_file_write_hex(file, "ATQA", data->atqa, 2)) break;
- if(!flipper_file_write_hex(file, "SAK", &data->sak, 1)) break;
+ if(!flipper_format_write_hex(file, "UID", data->uid, data->uid_len)) break;
+ if(!flipper_format_write_hex(file, "ATQA", data->atqa, 2)) break;
+ if(!flipper_format_write_hex(file, "SAK", &data->sak, 1)) break;
// Save more data if necessary
if(dev->format == NfcDeviceSaveFormatMifareUl) {
if(!nfc_device_save_mifare_ul_data(file, dev)) break;
@@ -272,8 +273,7 @@ static bool nfc_device_save_file(
dialog_message_show_storage_error(dev->dialogs, "Can not save\nkey file");
}
string_clear(temp_str);
- flipper_file_close(file);
- flipper_file_free(file);
+ flipper_format_free(file);
return saved;
}
@@ -288,7 +288,7 @@ bool nfc_device_save_shadow(NfcDevice* dev, const char* dev_name) {
static bool nfc_device_load_data(NfcDevice* dev, string_t path) {
bool parsed = false;
- FlipperFile* file = flipper_file_alloc(dev->storage);
+ FlipperFormat* file = flipper_format_file_alloc(dev->storage);
NfcDeviceCommonData* data = &dev->dev_data.nfc_data;
uint32_t data_cnt = 0;
string_t temp_str;
@@ -304,26 +304,26 @@ static bool nfc_device_load_data(NfcDevice* dev, string_t path) {
storage_common_stat(dev->storage, string_get_cstr(temp_str), NULL) == FSE_OK;
// Open shadow file if it exists. If not - open original
if(dev->shadow_file_exist) {
- if(!flipper_file_open_existing(file, string_get_cstr(temp_str))) break;
+ if(!flipper_format_file_open_existing(file, string_get_cstr(temp_str))) break;
} else {
- if(!flipper_file_open_existing(file, string_get_cstr(path))) break;
+ if(!flipper_format_file_open_existing(file, string_get_cstr(path))) break;
}
// Read and verify file header
uint32_t version = 0;
- if(!flipper_file_read_header(file, temp_str, &version)) break;
+ if(!flipper_format_read_header(file, temp_str, &version)) break;
if(string_cmp_str(temp_str, nfc_file_header) || (version != nfc_file_version)) {
depricated_version = true;
break;
}
// Read Nfc device type
- if(!flipper_file_read_string(file, "Device type", temp_str)) break;
+ if(!flipper_format_read_string(file, "Device type", temp_str)) break;
if(!nfc_device_parse_format_string(dev, temp_str)) break;
// Read and parse UID, ATQA and SAK
- if(!flipper_file_get_value_count(file, "UID", &data_cnt)) break;
+ if(!flipper_format_get_value_count(file, "UID", &data_cnt)) break;
data->uid_len = data_cnt;
- if(!flipper_file_read_hex(file, "UID", data->uid, data->uid_len)) break;
- if(!flipper_file_read_hex(file, "ATQA", data->atqa, 2)) break;
- if(!flipper_file_read_hex(file, "SAK", &data->sak, 1)) break;
+ if(!flipper_format_read_hex(file, "UID", data->uid, data->uid_len)) break;
+ if(!flipper_format_read_hex(file, "ATQA", data->atqa, 2)) break;
+ if(!flipper_format_read_hex(file, "SAK", &data->sak, 1)) break;
// Parse other data
if(dev->format == NfcDeviceSaveFormatMifareUl) {
if(!nfc_device_load_mifare_ul_data(file, dev)) break;
@@ -342,8 +342,7 @@ static bool nfc_device_load_data(NfcDevice* dev, string_t path) {
}
string_clear(temp_str);
- flipper_file_close(file);
- flipper_file_free(file);
+ flipper_format_free(file);
return parsed;
}
diff --git a/applications/nfc/nfc_worker.c b/applications/nfc/nfc_worker.c
index 4f969188..2056fd9f 100755
--- a/applications/nfc/nfc_worker.c
+++ b/applications/nfc/nfc_worker.c
@@ -8,18 +8,17 @@
/***************************** NFC Worker API *******************************/
NfcWorker* nfc_worker_alloc() {
- NfcWorker* nfc_worker = furi_alloc(sizeof(NfcWorker));
+ NfcWorker* nfc_worker = malloc(sizeof(NfcWorker));
// Worker thread attributes
nfc_worker->thread_attr.name = "NfcWorker";
nfc_worker->thread_attr.stack_size = 8192;
nfc_worker->callback = NULL;
nfc_worker->context = NULL;
// Initialize rfal
- if(!furi_hal_nfc_is_busy()) {
- nfc_worker_change_state(nfc_worker, NfcWorkerStateReady);
- } else {
- nfc_worker_change_state(nfc_worker, NfcWorkerStateBroken);
+ while(furi_hal_nfc_is_busy()) {
+ osDelay(10);
}
+ nfc_worker_change_state(nfc_worker, NfcWorkerStateReady);
return nfc_worker;
}
@@ -41,7 +40,7 @@ void nfc_worker_start(
void* context) {
furi_assert(nfc_worker);
furi_assert(dev_data);
- while(nfc_worker->state != NfcWorkerStateReady) {
+ while(furi_hal_nfc_is_busy()) {
osDelay(10);
}
diff --git a/applications/nfc/views/bank_card.c b/applications/nfc/views/bank_card.c
index ee54c4b0..31cc56ee 100755
--- a/applications/nfc/views/bank_card.c
+++ b/applications/nfc/views/bank_card.c
@@ -7,7 +7,7 @@ struct BankCard {
};
BankCard* bank_card_alloc() {
- BankCard* bank_card = furi_alloc(sizeof(BankCard));
+ BankCard* bank_card = malloc(sizeof(BankCard));
bank_card->widget = widget_alloc();
return bank_card;
}
diff --git a/applications/notification/notification_app.c b/applications/notification/notification_app.c
index 99d9bce8..9dfa4d1a 100644
--- a/applications/notification/notification_app.c
+++ b/applications/notification/notification_app.c
@@ -403,7 +403,7 @@ static void input_event_callback(const void* value, void* context) {
// App alloc
static NotificationApp* notification_app_alloc() {
- NotificationApp* app = furi_alloc(sizeof(NotificationApp));
+ NotificationApp* app = malloc(sizeof(NotificationApp));
app->queue = osMessageQueueNew(8, sizeof(NotificationAppMessage), NULL);
app->display_timer = osTimerNew(notification_display_timer, osTimerOnce, app, NULL);
@@ -482,4 +482,4 @@ int32_t notification_srv(void* p) {
}
return 0;
-}; \ No newline at end of file
+};
diff --git a/applications/notification/notification_settings_app.c b/applications/notification/notification_settings_app.c
index 6b60a98d..4f05a103 100644
--- a/applications/notification/notification_settings_app.c
+++ b/applications/notification/notification_settings_app.c
@@ -221,4 +221,4 @@ int32_t notification_settings_app(void* p) {
notification_message_save_settings(app->notification);
free_settings(app);
return 0;
-} \ No newline at end of file
+}
diff --git a/applications/power/battery_test_app/battery_test_app.c b/applications/power/battery_test_app/battery_test_app.c
index 33b2c65b..4d73fee5 100755
--- a/applications/power/battery_test_app/battery_test_app.c
+++ b/applications/power/battery_test_app/battery_test_app.c
@@ -32,7 +32,7 @@ static void battery_test_battery_info_update_model(void* context) {
}
BatteryTestApp* battery_test_alloc() {
- BatteryTestApp* app = furi_alloc(sizeof(BatteryTestApp));
+ BatteryTestApp* app = malloc(sizeof(BatteryTestApp));
// Records
app->gui = furi_record_open("gui");
@@ -97,4 +97,4 @@ int32_t battery_test_app(void* p) {
power_enable_low_battery_level_notification(app->power, true);
battery_test_free(app);
return 0;
-} \ No newline at end of file
+}
diff --git a/applications/power/power_service/power.c b/applications/power/power_service/power.c
index 3934b20d..8c2ecd17 100755
--- a/applications/power/power_service/power.c
+++ b/applications/power/power_service/power.c
@@ -32,7 +32,7 @@ static ViewPort* power_battery_view_port_alloc(Power* power) {
}
Power* power_alloc() {
- Power* power = furi_alloc(sizeof(Power));
+ Power* power = malloc(sizeof(Power));
// Records
power->notification = furi_record_open("notification");
diff --git a/applications/power/power_service/views/power_off.c b/applications/power/power_service/views/power_off.c
index 73abc16b..46344b9b 100755
--- a/applications/power/power_service/views/power_off.c
+++ b/applications/power/power_service/views/power_off.c
@@ -29,7 +29,7 @@ static void power_off_draw_callback(Canvas* canvas, void* _model) {
}
PowerOff* power_off_alloc() {
- PowerOff* power_off = furi_alloc(sizeof(PowerOff));
+ PowerOff* power_off = malloc(sizeof(PowerOff));
power_off->view = view_alloc();
view_allocate_model(power_off->view, ViewModelTypeLocking, sizeof(PowerOffModel));
view_set_draw_callback(power_off->view, power_off_draw_callback);
diff --git a/applications/power/power_settings_app/power_settings_app.c b/applications/power/power_settings_app/power_settings_app.c
index 8e77716e..1e87e7d6 100755
--- a/applications/power/power_settings_app/power_settings_app.c
+++ b/applications/power/power_settings_app/power_settings_app.c
@@ -19,7 +19,7 @@ static void power_settings_tick_event_callback(void* context) {
}
PowerSettingsApp* power_settings_app_alloc() {
- PowerSettingsApp* app = furi_alloc(sizeof(PowerSettingsApp));
+ PowerSettingsApp* app = malloc(sizeof(PowerSettingsApp));
// Records
app->gui = furi_record_open("gui");
diff --git a/applications/power/power_settings_app/views/battery_info.c b/applications/power/power_settings_app/views/battery_info.c
index 599aefee..aa3a1e96 100644
--- a/applications/power/power_settings_app/views/battery_info.c
+++ b/applications/power/power_settings_app/views/battery_info.c
@@ -95,7 +95,7 @@ static void battery_info_draw_callback(Canvas* canvas, void* context) {
}
BatteryInfo* battery_info_alloc() {
- BatteryInfo* battery_info = furi_alloc(sizeof(BatteryInfo));
+ BatteryInfo* battery_info = malloc(sizeof(BatteryInfo));
battery_info->view = view_alloc();
view_set_context(battery_info->view, battery_info);
view_allocate_model(battery_info->view, ViewModelTypeLocking, sizeof(BatteryInfoModel));
diff --git a/applications/rpc/rpc.c b/applications/rpc/rpc.c
index f76f455e..f4dfc31f 100644
--- a/applications/rpc/rpc.c
+++ b/applications/rpc/rpc.c
@@ -349,13 +349,13 @@ void rpc_print_message(const PB_Main* message) {
}
static Rpc* rpc_alloc(void) {
- Rpc* rpc = furi_alloc(sizeof(Rpc));
+ Rpc* rpc = malloc(sizeof(Rpc));
rpc->busy_mutex = osMutexNew(NULL);
rpc->busy = false;
rpc->events = osEventFlagsNew(NULL);
rpc->stream = xStreamBufferCreate(RPC_BUFFER_SIZE, 1);
- rpc->decoded_message = furi_alloc(sizeof(PB_Main));
+ rpc->decoded_message = malloc(sizeof(PB_Main));
rpc->decoded_message->cb_content.funcs.decode = content_callback;
rpc->decoded_message->cb_content.arg = rpc;
@@ -384,7 +384,7 @@ RpcSession* rpc_session_open(Rpc* rpc) {
session->decode_error = false;
xStreamBufferReset(rpc->stream);
- session->system_contexts = furi_alloc(COUNT_OF(rpc_systems) * sizeof(void*));
+ session->system_contexts = malloc(COUNT_OF(rpc_systems) * sizeof(void*));
for(int i = 0; i < COUNT_OF(rpc_systems); ++i) {
session->system_contexts[i] = rpc_systems[i].alloc(rpc);
}
@@ -554,7 +554,7 @@ void rpc_send_and_release(Rpc* rpc, PB_Main* message) {
bool result = pb_encode_ex(&ostream, &PB_Main_msg, message, PB_ENCODE_DELIMITED);
furi_check(result && ostream.bytes_written);
- uint8_t* buffer = furi_alloc(ostream.bytes_written);
+ uint8_t* buffer = malloc(ostream.bytes_written);
ostream = pb_ostream_from_buffer(buffer, ostream.bytes_written);
pb_encode_ex(&ostream, &PB_Main_msg, message, PB_ENCODE_DELIMITED);
diff --git a/applications/rpc/rpc_cli.c b/applications/rpc/rpc_cli.c
index 59f9458f..55cc3e49 100644
--- a/applications/rpc/rpc_cli.c
+++ b/applications/rpc/rpc_cli.c
@@ -40,7 +40,7 @@ void rpc_cli_command_start_session(Cli* cli, string_t args, void* context) {
rpc_session_set_send_bytes_callback(rpc_session, rpc_send_bytes_callback);
rpc_session_set_close_callback(rpc_session, rpc_session_close_callback);
- uint8_t* buffer = furi_alloc(CLI_READ_BUFFER_SIZE);
+ uint8_t* buffer = malloc(CLI_READ_BUFFER_SIZE);
size_t size_received = 0;
while(1) {
diff --git a/applications/rpc/rpc_gui.c b/applications/rpc/rpc_gui.c
index 8e3d2c46..7ee637a0 100644
--- a/applications/rpc/rpc_gui.c
+++ b/applications/rpc/rpc_gui.c
@@ -21,11 +21,11 @@ static void
RpcGuiSystem* rpc_gui = context;
- PB_Main* frame = furi_alloc(sizeof(PB_Main));
+ PB_Main* frame = malloc(sizeof(PB_Main));
frame->which_content = PB_Main_gui_screen_frame_tag;
frame->command_status = PB_CommandStatus_OK;
- frame->content.gui_screen_frame.data = furi_alloc(PB_BYTES_ARRAY_T_ALLOCSIZE(size));
+ frame->content.gui_screen_frame.data = malloc(PB_BYTES_ARRAY_T_ALLOCSIZE(size));
uint8_t* buffer = frame->content.gui_screen_frame.data->bytes;
uint16_t* frame_size_msg = &frame->content.gui_screen_frame.data->size;
*frame_size_msg = size;
@@ -160,7 +160,7 @@ static void rpc_system_gui_start_virtual_display_process(const PB_Main* request,
// Using display framebuffer size as an XBM buffer size is like comparing apples and oranges
// Glad they both are 1024 for now
size_t buffer_size = canvas_get_buffer_size(rpc_gui->gui->canvas);
- rpc_gui->virtual_display_buffer = furi_alloc(buffer_size);
+ rpc_gui->virtual_display_buffer = malloc(buffer_size);
if(request->content.gui_start_virtual_display_request.has_first_frame) {
size_t buffer_size = canvas_get_buffer_size(rpc_gui->gui->canvas);
@@ -223,7 +223,7 @@ static void rpc_system_gui_virtual_display_frame_process(const PB_Main* request,
void* rpc_system_gui_alloc(Rpc* rpc) {
furi_assert(rpc);
- RpcGuiSystem* rpc_gui = furi_alloc(sizeof(RpcGuiSystem));
+ RpcGuiSystem* rpc_gui = malloc(sizeof(RpcGuiSystem));
rpc_gui->gui = furi_record_open("gui");
rpc_gui->rpc = rpc;
diff --git a/applications/rpc/rpc_storage.c b/applications/rpc/rpc_storage.c
index bf50c7b1..ed43e48d 100644
--- a/applications/rpc/rpc_storage.c
+++ b/applications/rpc/rpc_storage.c
@@ -104,7 +104,7 @@ static void rpc_system_storage_info_process(const PB_Main* request, void* contex
RpcStorageSystem* rpc_storage = context;
rpc_system_storage_reset_state(rpc_storage, true);
- PB_Main* response = furi_alloc(sizeof(PB_Main));
+ PB_Main* response = malloc(sizeof(PB_Main));
response->command_id = request->command_id;
Storage* fs_api = furi_record_open("storage");
@@ -135,7 +135,7 @@ static void rpc_system_storage_stat_process(const PB_Main* request, void* contex
RpcStorageSystem* rpc_storage = context;
rpc_system_storage_reset_state(rpc_storage, true);
- PB_Main* response = furi_alloc(sizeof(PB_Main));
+ PB_Main* response = malloc(sizeof(PB_Main));
response->command_id = request->command_id;
Storage* fs_api = furi_record_open("storage");
@@ -178,7 +178,7 @@ static void rpc_system_storage_list_root(const PB_Main* request, void* context)
response.content.storage_list_response.file[i].data = NULL;
response.content.storage_list_response.file[i].size = 0;
response.content.storage_list_response.file[i].type = PB_Storage_File_FileType_DIR;
- char* str = furi_alloc(strlen(hard_coded_dirs[i]) + 1);
+ char* str = malloc(strlen(hard_coded_dirs[i]) + 1);
strcpy(str, hard_coded_dirs[i]);
response.content.storage_list_response.file[i].name = str;
}
@@ -221,7 +221,7 @@ static void rpc_system_storage_list_process(const PB_Main* request, void* contex
while(!finish) {
FileInfo fileinfo;
- char* name = furi_alloc(MAX_NAME_LENGTH + 1);
+ char* name = malloc(MAX_NAME_LENGTH + 1);
if(storage_dir_read(dir, &fileinfo, name, MAX_NAME_LENGTH)) {
if(i == COUNT_OF(list->file)) {
list->file_count = i;
@@ -259,7 +259,7 @@ static void rpc_system_storage_read_process(const PB_Main* request, void* contex
rpc_system_storage_reset_state(rpc_storage, true);
/* use same message memory to send reponse */
- PB_Main* response = furi_alloc(sizeof(PB_Main));
+ PB_Main* response = malloc(sizeof(PB_Main));
const char* path = request->content.storage_read_request.path;
Storage* fs_api = furi_record_open("storage");
File* file = storage_file_alloc(fs_api);
@@ -273,7 +273,7 @@ static void rpc_system_storage_read_process(const PB_Main* request, void* contex
response->command_status = PB_CommandStatus_OK;
response->content.storage_read_response.has_file = true;
response->content.storage_read_response.file.data =
- furi_alloc(PB_BYTES_ARRAY_T_ALLOCSIZE(MIN(size_left, MAX_DATA_SIZE)));
+ malloc(PB_BYTES_ARRAY_T_ALLOCSIZE(MIN(size_left, MAX_DATA_SIZE)));
uint8_t* buffer = response->content.storage_read_response.file.data->bytes;
uint16_t* read_size_msg = &response->content.storage_read_response.file.data->size;
@@ -357,7 +357,7 @@ static bool rpc_system_storage_is_dir_is_empty(Storage* fs_api, const char* path
if((error == FSE_OK) && (fileinfo.flags & FSF_DIRECTORY)) {
File* dir = storage_file_alloc(fs_api);
if(storage_dir_open(dir, path)) {
- char* name = furi_alloc(MAX_NAME_LENGTH);
+ char* name = malloc(MAX_NAME_LENGTH);
is_dir_is_empty = !storage_dir_read(dir, &fileinfo, name, MAX_NAME_LENGTH);
free(name);
}
@@ -508,7 +508,7 @@ static void rpc_system_storage_rename_process(const PB_Main* request, void* cont
void* rpc_system_storage_alloc(Rpc* rpc) {
furi_assert(rpc);
- RpcStorageSystem* rpc_storage = furi_alloc(sizeof(RpcStorageSystem));
+ RpcStorageSystem* rpc_storage = malloc(sizeof(RpcStorageSystem));
rpc_storage->api = furi_record_open("storage");
rpc_storage->rpc = rpc;
rpc_storage->state = RpcStorageStateIdle;
diff --git a/applications/rpc/rpc_system.c b/applications/rpc/rpc_system.c
index ed5b889a..e718ad8a 100644
--- a/applications/rpc/rpc_system.c
+++ b/applications/rpc/rpc_system.c
@@ -27,7 +27,7 @@ static void rpc_system_system_ping_process(const PB_Main* msg_request, void* con
const PB_System_PingRequest* request = &msg_request->content.system_ping_request;
PB_System_PingResponse* response = &msg_response.content.system_ping_response;
if(request->data && (request->data->size > 0)) {
- response->data = furi_alloc(PB_BYTES_ARRAY_T_ALLOCSIZE(request->data->size));
+ response->data = malloc(PB_BYTES_ARRAY_T_ALLOCSIZE(request->data->size));
memcpy(response->data->bytes, request->data->bytes, request->data->size);
response->data->size = request->data->size;
}
@@ -84,7 +84,7 @@ static void rpc_system_system_device_info_process(const PB_Main* request, void*
furi_assert(context);
Rpc* rpc = context;
- PB_Main* response = furi_alloc(sizeof(PB_Main));
+ PB_Main* response = malloc(sizeof(PB_Main));
response->command_id = request->command_id;
response->which_content = PB_Main_system_device_info_response_tag;
response->command_status = PB_CommandStatus_OK;
@@ -108,7 +108,7 @@ static void rpc_system_system_get_datetime_process(const PB_Main* request, void*
FuriHalRtcDateTime datetime;
furi_hal_rtc_get_datetime(&datetime);
- PB_Main* response = furi_alloc(sizeof(PB_Main));
+ PB_Main* response = malloc(sizeof(PB_Main));
response->command_id = request->command_id;
response->which_content = PB_Main_system_get_datetime_response_tag;
response->command_status = PB_CommandStatus_OK;
@@ -180,7 +180,7 @@ static void rpc_system_system_protobuf_version_process(const PB_Main* request, v
Rpc* rpc = context;
- PB_Main* response = furi_alloc(sizeof(PB_Main));
+ PB_Main* response = malloc(sizeof(PB_Main));
response->command_id = request->command_id;
response->has_next = false;
response->command_status = PB_CommandStatus_OK;
diff --git a/applications/snake_game/snake_game.c b/applications/snake_game/snake_game.c
index e3fde566..2bc0a6a3 100644
--- a/applications/snake_game/snake_game.c
+++ b/applications/snake_game/snake_game.c
@@ -317,7 +317,7 @@ int32_t snake_game_app(void* p) {
osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(SnakeEvent), NULL);
- SnakeState* snake_state = furi_alloc(sizeof(SnakeState));
+ SnakeState* snake_state = malloc(sizeof(SnakeState));
snake_game_init_game(snake_state);
ValueMutex state_mutex;
diff --git a/applications/storage/filesystem_api_defines.h b/applications/storage/filesystem_api_defines.h
index dc6d0679..e90e642f 100644
--- a/applications/storage/filesystem_api_defines.h
+++ b/applications/storage/filesystem_api_defines.h
@@ -9,6 +9,7 @@ extern "C" {
typedef enum {
FSAM_READ = (1 << 0), /**< Read access */
FSAM_WRITE = (1 << 1), /**< Write access */
+ FSAM_READ_WRITE = FSAM_READ | FSAM_WRITE, /**< Read and write access */
} FS_AccessMode;
/** Open mode flags */
diff --git a/applications/storage/storage_cli.c b/applications/storage/storage_cli.c
index 0c7dc4d8..07fa638f 100644
--- a/applications/storage/storage_cli.c
+++ b/applications/storage/storage_cli.c
@@ -143,7 +143,7 @@ static void storage_cli_read(Cli* cli, string_t path) {
if(storage_file_open(file, string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) {
const uint16_t read_size = 128;
uint16_t readed_size = 0;
- uint8_t* data = furi_alloc(read_size);
+ uint8_t* data = malloc(read_size);
printf("Size: %lu\r\n", (uint32_t)storage_file_size(file));
@@ -171,7 +171,7 @@ static void storage_cli_write(Cli* cli, string_t path) {
File* file = storage_file_alloc(api);
const uint16_t buffer_size = 512;
- uint8_t* buffer = furi_alloc(buffer_size);
+ uint8_t* buffer = malloc(buffer_size);
if(storage_file_open(file, string_get_cstr(path), FSAM_WRITE, FSOM_OPEN_APPEND)) {
printf("Just write your text data. New line by Ctrl+Enter, exit by Ctrl+C.\r\n");
@@ -230,7 +230,7 @@ static void storage_cli_read_chunks(Cli* cli, string_t path, string_t args) {
if(parsed_count == EOF || parsed_count != 1) {
storage_cli_print_usage();
} else if(storage_file_open(file, string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) {
- uint8_t* data = furi_alloc(buffer_size);
+ uint8_t* data = malloc(buffer_size);
uint64_t file_size = storage_file_size(file);
printf("Size: %lu\r\n", (uint32_t)file_size);
@@ -271,7 +271,7 @@ static void storage_cli_write_chunk(Cli* cli, string_t path, string_t args) {
if(storage_file_open(file, string_get_cstr(path), FSAM_WRITE, FSOM_OPEN_APPEND)) {
printf("Ready\r\n");
- uint8_t* buffer = furi_alloc(buffer_size);
+ uint8_t* buffer = malloc(buffer_size);
for(uint32_t i = 0; i < buffer_size; i++) {
buffer[i] = cli_getc(cli);
diff --git a/applications/storage/storage_external_api.c b/applications/storage/storage_external_api.c
index f55cbb3b..9acc9ea4 100644
--- a/applications/storage/storage_external_api.c
+++ b/applications/storage/storage_external_api.c
@@ -372,7 +372,7 @@ FS_Error storage_sd_status(Storage* storage) {
}
File* storage_file_alloc(Storage* storage) {
- File* file = furi_alloc(sizeof(File));
+ File* file = malloc(sizeof(File));
file->file_id = FILE_CLOSED;
file->storage = storage;
@@ -407,7 +407,7 @@ bool storage_simply_remove_recursive(Storage* storage, const char* path) {
return true;
}
- char* name = furi_alloc(MAX_NAME_LENGTH + 1);
+ char* name = malloc(MAX_NAME_LENGTH + 1);
File* dir = storage_file_alloc(storage);
string_init_set_str(cur_dir, path);
bool go_deeper = false;
diff --git a/applications/storage/storage_test_app.c b/applications/storage/storage_test_app.c
index 4c4f08a2..79569116 100644
--- a/applications/storage/storage_test_app.c
+++ b/applications/storage/storage_test_app.c
@@ -338,4 +338,4 @@ int32_t storage_test_app(void* p) {
}
return 0;
-} \ No newline at end of file
+}
diff --git a/applications/storage/storages/storage_ext.c b/applications/storage/storages/storage_ext.c
index 8eacba4e..309ec1cf 100644
--- a/applications/storage/storages/storage_ext.c
+++ b/applications/storage/storages/storage_ext.c
@@ -512,7 +512,7 @@ static FS_Error storage_ext_common_fs_info(
/******************* Init Storage *******************/
void storage_ext_init(StorageData* storage) {
- SDData* sd_data = furi_alloc(sizeof(SDData));
+ SDData* sd_data = malloc(sizeof(SDData));
sd_data->fs = &USERFatFS;
sd_data->path = "0:/";
sd_data->sd_was_present = true;
diff --git a/applications/storage/storages/storage_int.c b/applications/storage/storages/storage_int.c
index 5c3223ed..811a1d6a 100644
--- a/applications/storage/storages/storage_int.c
+++ b/applications/storage/storages/storage_int.c
@@ -18,14 +18,14 @@ typedef struct {
} LFSHandle;
static LFSHandle* lfs_handle_alloc_file() {
- LFSHandle* handle = furi_alloc(sizeof(LFSHandle));
- handle->data = furi_alloc(sizeof(lfs_file_t));
+ LFSHandle* handle = malloc(sizeof(LFSHandle));
+ handle->data = malloc(sizeof(lfs_file_t));
return handle;
}
static LFSHandle* lfs_handle_alloc_dir() {
- LFSHandle* handle = furi_alloc(sizeof(LFSHandle));
- handle->data = furi_alloc(sizeof(lfs_dir_t));
+ LFSHandle* handle = malloc(sizeof(LFSHandle));
+ handle->data = malloc(sizeof(lfs_dir_t));
return handle;
}
@@ -134,7 +134,7 @@ static int storage_int_device_sync(const struct lfs_config* c) {
}
static LFSData* storage_int_lfs_data_alloc() {
- LFSData* lfs_data = furi_alloc(sizeof(LFSData));
+ LFSData* lfs_data = malloc(sizeof(LFSData));
// Internal storage start address
*(size_t*)(&lfs_data->start_address) = furi_hal_flash_get_free_page_start_address();
diff --git a/applications/storage_settings/storage_settings.c b/applications/storage_settings/storage_settings.c
index ac61cd3b..bc982b16 100644
--- a/applications/storage_settings/storage_settings.c
+++ b/applications/storage_settings/storage_settings.c
@@ -72,4 +72,4 @@ int32_t storage_settings_app(void* p) {
storage_settings_free(app);
return 0;
-} \ No newline at end of file
+}
diff --git a/applications/subghz/helpers/subghz_chat.c b/applications/subghz/helpers/subghz_chat.c
index 4bc79b89..38529a10 100644
--- a/applications/subghz/helpers/subghz_chat.c
+++ b/applications/subghz/helpers/subghz_chat.c
@@ -52,7 +52,7 @@ static void subghz_chat_worker_update_rx_event_chat(void* context) {
}
SubGhzChatWorker* subghz_chat_worker_alloc() {
- SubGhzChatWorker* instance = furi_alloc(sizeof(SubGhzChatWorker));
+ SubGhzChatWorker* instance = malloc(sizeof(SubGhzChatWorker));
instance->thread = furi_thread_alloc();
furi_thread_set_name(instance->thread, "SubghzChat");
@@ -138,4 +138,4 @@ size_t subghz_chat_worker_read(SubGhzChatWorker* instance, uint8_t* data, size_t
bool subghz_chat_worker_write(SubGhzChatWorker* instance, uint8_t* data, size_t size) {
furi_assert(instance);
return subghz_tx_rx_worker_write(instance->subghz_txrx, data, size);
-} \ No newline at end of file
+}
diff --git a/applications/subghz/helpers/subghz_frequency_analyzer_worker.c b/applications/subghz/helpers/subghz_frequency_analyzer_worker.c
index ddf557a6..b79cfe04 100644
--- a/applications/subghz/helpers/subghz_frequency_analyzer_worker.c
+++ b/applications/subghz/helpers/subghz_frequency_analyzer_worker.c
@@ -142,7 +142,7 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
}
SubGhzFrequencyAnalyzerWorker* subghz_frequency_analyzer_worker_alloc() {
- SubGhzFrequencyAnalyzerWorker* instance = furi_alloc(sizeof(SubGhzFrequencyAnalyzerWorker));
+ SubGhzFrequencyAnalyzerWorker* instance = malloc(sizeof(SubGhzFrequencyAnalyzerWorker));
instance->thread = furi_thread_alloc();
furi_thread_set_name(instance->thread, "SubghzFAWorker");
diff --git a/applications/subghz/subghz.c b/applications/subghz/subghz.c
index 4f442562..705be7d4 100644
--- a/applications/subghz/subghz.c
+++ b/applications/subghz/subghz.c
@@ -74,7 +74,7 @@ void subghz_tick_event_callback(void* context) {
}
SubGhz* subghz_alloc() {
- SubGhz* subghz = furi_alloc(sizeof(SubGhz));
+ SubGhz* subghz = malloc(sizeof(SubGhz));
// GUI
subghz->gui = furi_record_open("gui");
@@ -177,7 +177,7 @@ SubGhz* subghz_alloc() {
subghz_test_static_get_view(subghz->subghz_test_static));
//init Worker & Protocol & History
- subghz->txrx = furi_alloc(sizeof(SubGhzTxRx));
+ subghz->txrx = malloc(sizeof(SubGhzTxRx));
subghz->txrx->frequency = subghz_frequencies[subghz_frequencies_433_92];
subghz->txrx->preset = FuriHalSubGhzPresetOok650Async;
subghz->txrx->txrx_state = SubGhzTxRxStateSleep;
diff --git a/applications/subghz/subghz_cli.c b/applications/subghz/subghz_cli.c
index c54533d9..37946298 100644
--- a/applications/subghz/subghz_cli.c
+++ b/applications/subghz/subghz_cli.c
@@ -210,7 +210,7 @@ void subghz_cli_command_rx(Cli* cli, string_t args, void* context) {
}
// Allocate context and buffers
- SubGhzCliCommandRx* instance = furi_alloc(sizeof(SubGhzCliCommandRx));
+ SubGhzCliCommandRx* instance = malloc(sizeof(SubGhzCliCommandRx));
instance->stream = xStreamBufferCreate(sizeof(LevelDuration) * 1024, sizeof(LevelDuration));
furi_check(instance->stream);
diff --git a/applications/subghz/subghz_history.c b/applications/subghz/subghz_history.c
index ad6c3d4c..bb821e40 100644
--- a/applications/subghz/subghz_history.c
+++ b/applications/subghz/subghz_history.c
@@ -31,7 +31,7 @@ struct SubGhzHistory {
};
SubGhzHistory* subghz_history_alloc(void) {
- SubGhzHistory* instance = furi_alloc(sizeof(SubGhzHistory));
+ SubGhzHistory* instance = malloc(sizeof(SubGhzHistory));
return instance;
}
diff --git a/applications/subghz/subghz_i.c b/applications/subghz/subghz_i.c
index 87537ca2..5eb99f85 100755
--- a/applications/subghz/subghz_i.c
+++ b/applications/subghz/subghz_i.c
@@ -6,7 +6,7 @@
#include <input/input.h>
#include <gui/elements.h>
#include <notification/notification_messages.h>
-#include <lib/flipper_file/flipper_file.h>
+#include <flipper_format/flipper_format.h>
#include "../notification/notification.h"
#include "views/subghz_receiver.h"
@@ -198,7 +198,7 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path) {
furi_assert(file_path);
Storage* storage = furi_record_open("storage");
- FlipperFile* flipper_file = flipper_file_alloc(storage);
+ FlipperFormat* flipper_format = flipper_format_file_alloc(storage);
// Load device data
bool loaded = false;
@@ -209,12 +209,12 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path) {
uint32_t version;
do {
- if(!flipper_file_open_existing(flipper_file, string_get_cstr(path))) {
+ if(!flipper_format_file_open_existing(flipper_format, string_get_cstr(path))) {
FURI_LOG_E(
SUBGHZ_PARSER_TAG, "Unable to open file for read: %s", string_get_cstr(path));
break;
}
- if(!flipper_file_read_header(flipper_file, temp_str, &version)) {
+ if(!flipper_format_read_header(flipper_format, temp_str, &version)) {
FURI_LOG_E(SUBGHZ_PARSER_TAG, "Missing or incorrect header");
break;
}
@@ -227,13 +227,13 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path) {
break;
}
- if(!flipper_file_read_uint32(
- flipper_file, "Frequency", (uint32_t*)&subghz->txrx->frequency, 1)) {
+ if(!flipper_format_read_uint32(
+ flipper_format, "Frequency", (uint32_t*)&subghz->txrx->frequency, 1)) {
FURI_LOG_E(SUBGHZ_PARSER_TAG, "Missing Frequency");
break;
}
- if(!flipper_file_read_string(flipper_file, "Preset", temp_str)) {
+ if(!flipper_format_read_string(flipper_format, "Preset", temp_str)) {
FURI_LOG_E(SUBGHZ_PARSER_TAG, "Missing Preset");
break;
}
@@ -241,7 +241,7 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path) {
break;
}
- if(!flipper_file_read_string(flipper_file, "Protocol", temp_str)) {
+ if(!flipper_format_read_string(flipper_format, "Protocol", temp_str)) {
FURI_LOG_E(SUBGHZ_PARSER_TAG, "Missing Protocol");
break;
}
@@ -253,7 +253,7 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path) {
break;
}
if(!subghz->txrx->protocol_result->to_load_protocol_from_file(
- flipper_file, subghz->txrx->protocol_result, string_get_cstr(path))) {
+ flipper_format, subghz->txrx->protocol_result, string_get_cstr(path))) {
break;
}
loaded = true;
@@ -265,8 +265,7 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path) {
string_clear(temp_str);
string_clear(path);
- flipper_file_close(flipper_file);
- flipper_file_free(flipper_file);
+ flipper_format_free(flipper_format);
furi_record_close("storage");
@@ -301,7 +300,7 @@ bool subghz_save_protocol_to_file(SubGhz* subghz, const char* dev_name) {
furi_assert(subghz->txrx->protocol_result);
Storage* storage = furi_record_open("storage");
- FlipperFile* flipper_file = flipper_file_alloc(storage);
+ FlipperFormat* flipper_format = flipper_format_file_alloc(storage);
string_t dev_file_name;
string_init(dev_file_name);
string_t temp_str;
@@ -328,18 +327,18 @@ bool subghz_save_protocol_to_file(SubGhz* subghz, const char* dev_name) {
}
// Open file
- if(!flipper_file_open_always(flipper_file, string_get_cstr(dev_file_name))) {
+ if(!flipper_format_file_open_always(flipper_format, string_get_cstr(dev_file_name))) {
FURI_LOG_E(SUBGHZ_PARSER_TAG, "Unable to open file for write: %s", dev_file_name);
break;
}
- if(!flipper_file_write_header_cstr(
- flipper_file, SUBGHZ_KEY_FILE_TYPE, SUBGHZ_KEY_FILE_VERSION)) {
+ if(!flipper_format_write_header_cstr(
+ flipper_format, SUBGHZ_KEY_FILE_TYPE, SUBGHZ_KEY_FILE_VERSION)) {
FURI_LOG_E(SUBGHZ_PARSER_TAG, "Unable to add header");
break;
}
- if(!flipper_file_write_uint32(flipper_file, "Frequency", &subghz->txrx->frequency, 1)) {
+ if(!flipper_format_write_uint32(flipper_format, "Frequency", &subghz->txrx->frequency, 1)) {
FURI_LOG_E(SUBGHZ_PARSER_TAG, "Unable to add Frequency");
break;
}
@@ -347,13 +346,13 @@ bool subghz_save_protocol_to_file(SubGhz* subghz, const char* dev_name) {
if(!subghz_get_preset_name(subghz, temp_str)) {
break;
}
- if(!flipper_file_write_string_cstr(flipper_file, "Preset", string_get_cstr(temp_str))) {
+ if(!flipper_format_write_string_cstr(flipper_format, "Preset", string_get_cstr(temp_str))) {
FURI_LOG_E(SUBGHZ_PARSER_TAG, "Unable to add Preset");
break;
}
if(!subghz->txrx->protocol_result->to_save_file(
- subghz->txrx->protocol_result, flipper_file)) {
+ subghz->txrx->protocol_result, flipper_format)) {
break;
}
@@ -363,8 +362,7 @@ bool subghz_save_protocol_to_file(SubGhz* subghz, const char* dev_name) {
string_clear(temp_str);
string_clear(dev_file_name);
- flipper_file_close(flipper_file);
- flipper_file_free(flipper_file);
+ flipper_format_free(flipper_format);
furi_record_close("storage");
diff --git a/applications/subghz/views/subghz_frequency_analyzer.c b/applications/subghz/views/subghz_frequency_analyzer.c
index 1cc3d4f9..afb7b012 100644
--- a/applications/subghz/views/subghz_frequency_analyzer.c
+++ b/applications/subghz/views/subghz_frequency_analyzer.c
@@ -136,7 +136,7 @@ void subghz_frequency_analyzer_exit(void* context) {
}
SubghzFrequencyAnalyzer* subghz_frequency_analyzer_alloc() {
- SubghzFrequencyAnalyzer* instance = furi_alloc(sizeof(SubghzFrequencyAnalyzer));
+ SubghzFrequencyAnalyzer* instance = malloc(sizeof(SubghzFrequencyAnalyzer));
// View allocation and configuration
instance->view = view_alloc();
@@ -167,4 +167,4 @@ void subghz_frequency_analyzer_free(SubghzFrequencyAnalyzer* instance) {
View* subghz_frequency_analyzer_get_view(SubghzFrequencyAnalyzer* instance) {
furi_assert(instance);
return instance->view;
-} \ No newline at end of file
+}
diff --git a/applications/subghz/views/subghz_read_raw.c b/applications/subghz/views/subghz_read_raw.c
index 27d1c31f..f786b7a0 100644
--- a/applications/subghz/views/subghz_read_raw.c
+++ b/applications/subghz/views/subghz_read_raw.c
@@ -484,7 +484,7 @@ void subghz_read_raw_exit(void* context) {
}
SubghzReadRAW* subghz_read_raw_alloc() {
- SubghzReadRAW* instance = furi_alloc(sizeof(SubghzReadRAW));
+ SubghzReadRAW* instance = malloc(sizeof(SubghzReadRAW));
// View allocation and configuration
instance->view = view_alloc();
@@ -501,7 +501,7 @@ SubghzReadRAW* subghz_read_raw_alloc() {
string_init(model->preset_str);
string_init(model->sample_write);
string_init(model->file_name);
- model->rssi_history = furi_alloc(SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE * sizeof(uint8_t));
+ model->rssi_history = malloc(SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE * sizeof(uint8_t));
return true;
});
@@ -527,4 +527,4 @@ void subghz_read_raw_free(SubghzReadRAW* instance) {
View* subghz_read_raw_get_view(SubghzReadRAW* instance) {
furi_assert(instance);
return instance->view;
-} \ No newline at end of file
+}
diff --git a/applications/subghz/views/subghz_receiver.c b/applications/subghz/views/subghz_receiver.c
index b158d870..92bfbb53 100644
--- a/applications/subghz/views/subghz_receiver.c
+++ b/applications/subghz/views/subghz_receiver.c
@@ -243,7 +243,7 @@ void subghz_receiver_exit(void* context) {
}
SubghzReceiver* subghz_receiver_alloc() {
- SubghzReceiver* subghz_receiver = furi_alloc(sizeof(SubghzReceiver));
+ SubghzReceiver* subghz_receiver = malloc(sizeof(SubghzReceiver));
// View allocation and configuration
subghz_receiver->view = view_alloc();
@@ -259,7 +259,7 @@ SubghzReceiver* subghz_receiver_alloc() {
string_init(model->frequency_str);
string_init(model->preset_str);
string_init(model->history_stat_str);
- model->history = furi_alloc(sizeof(SubGhzReceiverHistory));
+ model->history = malloc(sizeof(SubGhzReceiverHistory));
SubGhzReceiverMenuItemArray_init(model->history->data);
return true;
});
@@ -313,4 +313,4 @@ void subghz_receiver_set_idx_menu(SubghzReceiver* subghz_receiver, uint16_t idx)
return true;
});
subghz_receiver_update_offset(subghz_receiver);
-} \ No newline at end of file
+}
diff --git a/applications/subghz/views/subghz_test_carrier.c b/applications/subghz/views/subghz_test_carrier.c
index 4d7b1189..82d95bff 100644
--- a/applications/subghz/views/subghz_test_carrier.c
+++ b/applications/subghz/views/subghz_test_carrier.c
@@ -181,7 +181,7 @@ void subghz_test_carrier_rssi_timer_callback(void* context) {
}
SubghzTestCarrier* subghz_test_carrier_alloc() {
- SubghzTestCarrier* subghz_test_carrier = furi_alloc(sizeof(SubghzTestCarrier));
+ SubghzTestCarrier* subghz_test_carrier = malloc(sizeof(SubghzTestCarrier));
// View allocation and configuration
subghz_test_carrier->view = view_alloc();
diff --git a/applications/subghz/views/subghz_test_packet.c b/applications/subghz/views/subghz_test_packet.c
index 335afbb9..c856dc74 100644
--- a/applications/subghz/views/subghz_test_packet.c
+++ b/applications/subghz/views/subghz_test_packet.c
@@ -227,7 +227,7 @@ void subghz_test_packet_exit(void* context) {
}
SubghzTestPacket* subghz_test_packet_alloc() {
- SubghzTestPacket* instance = furi_alloc(sizeof(SubghzTestPacket));
+ SubghzTestPacket* instance = malloc(sizeof(SubghzTestPacket));
// View allocation and configuration
instance->view = view_alloc();
diff --git a/applications/subghz/views/subghz_test_static.c b/applications/subghz/views/subghz_test_static.c
index d3485d73..35001bdc 100644
--- a/applications/subghz/views/subghz_test_static.c
+++ b/applications/subghz/views/subghz_test_static.c
@@ -161,7 +161,7 @@ void subghz_test_static_exit(void* context) {
}
SubghzTestStatic* subghz_test_static_alloc() {
- SubghzTestStatic* instance = furi_alloc(sizeof(SubghzTestStatic));
+ SubghzTestStatic* instance = malloc(sizeof(SubghzTestStatic));
// View allocation and configuration
instance->view = view_alloc();
@@ -187,4 +187,4 @@ void subghz_test_static_free(SubghzTestStatic* instance) {
View* subghz_test_static_get_view(SubghzTestStatic* instance) {
furi_assert(instance);
return instance->view;
-} \ No newline at end of file
+}
diff --git a/applications/subghz/views/subghz_transmitter.c b/applications/subghz/views/subghz_transmitter.c
index b9421e4f..f1afccfa 100644
--- a/applications/subghz/views/subghz_transmitter.c
+++ b/applications/subghz/views/subghz_transmitter.c
@@ -134,7 +134,7 @@ void subghz_transmitter_exit(void* context) {
}
SubghzTransmitter* subghz_transmitter_alloc() {
- SubghzTransmitter* subghz_transmitter = furi_alloc(sizeof(SubghzTransmitter));
+ SubghzTransmitter* subghz_transmitter = malloc(sizeof(SubghzTransmitter));
// View allocation and configuration
subghz_transmitter->view = view_alloc();
diff --git a/applications/system/system_settings.c b/applications/system/system_settings.c
index 7d48451f..fde07745 100644
--- a/applications/system/system_settings.c
+++ b/applications/system/system_settings.c
@@ -63,7 +63,7 @@ static uint32_t system_settings_exit(void* context) {
}
SystemSettings* system_settings_alloc() {
- SystemSettings* app = furi_alloc(sizeof(SystemSettings));
+ SystemSettings* app = malloc(sizeof(SystemSettings));
// Load settings
app->gui = furi_record_open("gui");
diff --git a/applications/tests/flipper_format/flipper_format_string_test.c b/applications/tests/flipper_format/flipper_format_string_test.c
new file mode 100644
index 00000000..9986c523
--- /dev/null
+++ b/applications/tests/flipper_format/flipper_format_string_test.c
@@ -0,0 +1,227 @@
+#include <furi.h>
+#include <flipper_format/flipper_format.h>
+#include <flipper_format/flipper_format_i.h>
+#include <toolbox/stream/stream.h>
+#include <storage/storage.h>
+#include "../minunit.h"
+
+static const char* test_filetype = "Flipper Format test";
+static const uint32_t test_version = 666;
+
+static const char* test_string_key = "String data";
+static const char* test_string_data = "String";
+static const char* test_string_updated_data = "New string";
+
+static const char* test_int_key = "Int32 data";
+static const int32_t test_int_data[] = {1234, -6345, 7813, 0};
+static const int32_t test_int_updated_data[] = {-1337, 69};
+
+static const char* test_uint_key = "Uint32 data";
+static const uint32_t test_uint_data[] = {1234, 0, 5678, 9098, 7654321};
+static const uint32_t test_uint_updated_data[] = {8, 800, 555, 35, 35};
+
+static const char* test_float_key = "Float data";
+static const float test_float_data[] = {1.5f, 1000.0f};
+static const float test_float_updated_data[] = {1.2f};
+
+static const char* test_hex_key = "Hex data";
+static const uint8_t test_hex_data[] = {0xDE, 0xAD, 0xBE};
+static const uint8_t test_hex_updated_data[] = {0xFE, 0xCA};
+
+static const char* test_data_nix = "Filetype: Flipper Format test\n"
+ "Version: 666\n"
+ "# This is comment\n"
+ "String data: String\n"
+ "Int32 data: 1234 -6345 7813 0\n"
+ "Uint32 data: 1234 0 5678 9098 7654321\n"
+ "Float data: 1.5 1000.0\n"
+ "Hex data: DE AD BE";
+
+static const char* test_data_win = "Filetype: Flipper Format test\r\n"
+ "Version: 666\r\n"
+ "# This is comment\r\n"
+ "String data: String\r\n"
+ "Int32 data: 1234 -6345 7813 0\r\n"
+ "Uint32 data: 1234 0 5678 9098 7654321\r\n"
+ "Float data: 1.5 1000.0\r\n"
+ "Hex data: DE AD BE";
+
+#define ARRAY_W_COUNT(x) (x), (COUNT_OF(x))
+#define ARRAY_W_BSIZE(x) (x), (sizeof(x))
+
+MU_TEST_1(flipper_format_read_and_update_test, FlipperFormat* flipper_format) {
+ string_t tmpstr;
+ uint32_t version;
+ uint32_t uint32_data[COUNT_OF(test_uint_data)];
+ int32_t int32_data[COUNT_OF(test_int_data)];
+ float float_data[COUNT_OF(test_float_data)];
+ uint8_t hex_data[COUNT_OF(test_hex_data)];
+
+ uint32_t count;
+
+ mu_check(flipper_format_rewind(flipper_format));
+ string_init(tmpstr);
+
+ mu_check(flipper_format_read_header(flipper_format, tmpstr, &version));
+ mu_assert_string_eq(test_filetype, string_get_cstr(tmpstr));
+ mu_assert_int_eq(test_version, version);
+
+ mu_check(flipper_format_read_string(flipper_format, test_string_key, tmpstr));
+ mu_assert_string_eq(test_string_data, string_get_cstr(tmpstr));
+
+ mu_check(flipper_format_get_value_count(flipper_format, test_int_key, &count));
+ mu_assert_int_eq(COUNT_OF(test_int_data), count);
+ mu_check(flipper_format_read_int32(flipper_format, test_int_key, ARRAY_W_COUNT(int32_data)));
+ mu_check(memcmp(test_int_data, ARRAY_W_BSIZE(int32_data)) == 0);
+
+ mu_check(flipper_format_get_value_count(flipper_format, test_uint_key, &count));
+ mu_assert_int_eq(COUNT_OF(test_uint_data), count);
+ mu_check(
+ flipper_format_read_uint32(flipper_format, test_uint_key, ARRAY_W_COUNT(uint32_data)));
+ mu_check(memcmp(test_uint_data, ARRAY_W_BSIZE(uint32_data)) == 0);
+
+ mu_check(flipper_format_get_value_count(flipper_format, test_float_key, &count));
+ mu_assert_int_eq(COUNT_OF(test_float_data), count);
+ mu_check(flipper_format_read_float(flipper_format, test_float_key, ARRAY_W_COUNT(float_data)));
+ mu_check(memcmp(test_float_data, ARRAY_W_BSIZE(float_data)) == 0);
+
+ mu_check(flipper_format_get_value_count(flipper_format, test_hex_key, &count));
+ mu_assert_int_eq(COUNT_OF(test_hex_data), count);
+ mu_check(flipper_format_read_hex(flipper_format, test_hex_key, ARRAY_W_COUNT(hex_data)));
+ mu_check(memcmp(test_hex_data, ARRAY_W_BSIZE(hex_data)) == 0);
+
+ mu_check(!flipper_format_read_string(flipper_format, "Key that doesn't exist", tmpstr));
+
+ string_clear(tmpstr);
+
+ mu_check(flipper_format_rewind(flipper_format));
+ mu_check(flipper_format_update_string_cstr(
+ flipper_format, test_string_key, test_string_updated_data));
+ mu_check(flipper_format_update_int32(
+ flipper_format, test_int_key, ARRAY_W_COUNT(test_int_updated_data)));
+ mu_check(flipper_format_update_uint32(
+ flipper_format, test_uint_key, ARRAY_W_COUNT(test_uint_updated_data)));
+ mu_check(flipper_format_update_float(
+ flipper_format, test_float_key, ARRAY_W_COUNT(test_float_updated_data)));
+ mu_check(flipper_format_update_hex(
+ flipper_format, test_hex_key, ARRAY_W_COUNT(test_hex_updated_data)));
+
+ uint32_t uint32_updated_data[COUNT_OF(test_uint_updated_data)];
+ int32_t int32_updated_data[COUNT_OF(test_int_updated_data)];
+ float float_updated_data[COUNT_OF(test_float_updated_data)];
+ uint8_t hex_updated_data[COUNT_OF(test_hex_updated_data)];
+
+ mu_check(flipper_format_rewind(flipper_format));
+ string_init(tmpstr);
+
+ mu_check(flipper_format_read_header(flipper_format, tmpstr, &version));
+ mu_assert_string_eq(test_filetype, string_get_cstr(tmpstr));
+ mu_assert_int_eq(test_version, version);
+
+ mu_check(flipper_format_read_string(flipper_format, test_string_key, tmpstr));
+ mu_assert_string_eq(test_string_updated_data, string_get_cstr(tmpstr));
+
+ mu_check(flipper_format_get_value_count(flipper_format, test_int_key, &count));
+ mu_assert_int_eq(COUNT_OF(test_int_updated_data), count);
+ mu_check(flipper_format_read_int32(
+ flipper_format, test_int_key, ARRAY_W_COUNT(int32_updated_data)));
+ mu_check(memcmp(test_int_updated_data, ARRAY_W_BSIZE(int32_updated_data)) == 0);
+
+ mu_check(flipper_format_get_value_count(flipper_format, test_uint_key, &count));
+ mu_assert_int_eq(COUNT_OF(test_uint_updated_data), count);
+ mu_check(flipper_format_read_uint32(
+ flipper_format, test_uint_key, ARRAY_W_COUNT(uint32_updated_data)));
+ mu_check(memcmp(test_uint_updated_data, ARRAY_W_BSIZE(uint32_updated_data)) == 0);
+
+ mu_check(flipper_format_get_value_count(flipper_format, test_float_key, &count));
+ mu_assert_int_eq(COUNT_OF(test_float_updated_data), count);
+ mu_check(flipper_format_read_float(
+ flipper_format, test_float_key, ARRAY_W_COUNT(float_updated_data)));
+ mu_check(memcmp(test_float_updated_data, ARRAY_W_BSIZE(float_updated_data)) == 0);
+
+ mu_check(flipper_format_get_value_count(flipper_format, test_hex_key, &count));
+ mu_assert_int_eq(COUNT_OF(test_hex_updated_data), count);
+ mu_check(
+ flipper_format_read_hex(flipper_format, test_hex_key, ARRAY_W_COUNT(hex_updated_data)));
+ mu_check(memcmp(test_hex_updated_data, ARRAY_W_BSIZE(hex_updated_data)) == 0);
+
+ mu_check(!flipper_format_read_string(flipper_format, "Key that doesn't exist", tmpstr));
+
+ string_clear(tmpstr);
+
+ mu_check(flipper_format_rewind(flipper_format));
+ mu_check(flipper_format_delete_key(flipper_format, test_uint_key));
+
+ mu_check(flipper_format_rewind(flipper_format));
+ mu_check(!flipper_format_read_uint32(
+ flipper_format, test_uint_key, ARRAY_W_COUNT(uint32_updated_data)));
+}
+
+MU_TEST(flipper_format_string_test) {
+ FlipperFormat* flipper_format = flipper_format_string_alloc();
+ Stream* stream = flipper_format_get_raw_stream(flipper_format);
+
+ mu_check(flipper_format_write_header_cstr(flipper_format, test_filetype, test_version));
+ mu_check(flipper_format_write_comment_cstr(flipper_format, "This is comment"));
+ mu_check(flipper_format_write_string_cstr(flipper_format, test_string_key, test_string_data));
+ mu_check(
+ flipper_format_write_int32(flipper_format, test_int_key, ARRAY_W_COUNT(test_int_data)));
+ mu_check(
+ flipper_format_write_uint32(flipper_format, test_uint_key, ARRAY_W_COUNT(test_uint_data)));
+ mu_check(flipper_format_write_float(
+ flipper_format, test_float_key, ARRAY_W_COUNT(test_float_data)));
+ mu_check(flipper_format_write_hex(flipper_format, test_hex_key, ARRAY_W_COUNT(test_hex_data)));
+
+ MU_RUN_TEST_1(flipper_format_read_and_update_test, flipper_format);
+
+ stream_clean(stream);
+ stream_write_cstring(stream, test_data_nix);
+ MU_RUN_TEST_1(flipper_format_read_and_update_test, flipper_format);
+
+ stream_clean(stream);
+ stream_write_cstring(stream, test_data_win);
+ MU_RUN_TEST_1(flipper_format_read_and_update_test, flipper_format);
+
+ flipper_format_free(flipper_format);
+}
+
+MU_TEST(flipper_format_file_test) {
+ Storage* storage = furi_record_open("storage");
+ FlipperFormat* flipper_format = flipper_format_file_alloc(storage);
+ mu_check(flipper_format_file_open_always(flipper_format, "/ext/flipper.fff"));
+ Stream* stream = flipper_format_get_raw_stream(flipper_format);
+
+ mu_check(flipper_format_write_header_cstr(flipper_format, test_filetype, test_version));
+ mu_check(flipper_format_write_comment_cstr(flipper_format, "This is comment"));
+ mu_check(flipper_format_write_string_cstr(flipper_format, test_string_key, test_string_data));
+ mu_check(
+ flipper_format_write_int32(flipper_format, test_int_key, ARRAY_W_COUNT(test_int_data)));
+ mu_check(
+ flipper_format_write_uint32(flipper_format, test_uint_key, ARRAY_W_COUNT(test_uint_data)));
+ mu_check(flipper_format_write_float(
+ flipper_format, test_float_key, ARRAY_W_COUNT(test_float_data)));
+ mu_check(flipper_format_write_hex(flipper_format, test_hex_key, ARRAY_W_COUNT(test_hex_data)));
+
+ MU_RUN_TEST_1(flipper_format_read_and_update_test, flipper_format);
+
+ stream_clean(stream);
+ stream_write_cstring(stream, test_data_nix);
+ MU_RUN_TEST_1(flipper_format_read_and_update_test, flipper_format);
+
+ stream_clean(stream);
+ stream_write_cstring(stream, test_data_win);
+ MU_RUN_TEST_1(flipper_format_read_and_update_test, flipper_format);
+
+ flipper_format_free(flipper_format);
+ furi_record_close("storage");
+}
+
+MU_TEST_SUITE(flipper_format_string_suite) {
+ MU_RUN_TEST(flipper_format_string_test);
+ MU_RUN_TEST(flipper_format_file_test);
+}
+
+int run_minunit_test_flipper_format_string() {
+ MU_RUN_SUITE(flipper_format_string_suite);
+ return MU_EXIT_CODE;
+} \ No newline at end of file
diff --git a/applications/tests/flipper_file/flipper_file_test.c b/applications/tests/flipper_format/flipper_format_test.c
index 8d21bb42..62171817 100644
--- a/applications/tests/flipper_file/flipper_file_test.c
+++ b/applications/tests/flipper_format/flipper_format_test.c
@@ -1,5 +1,7 @@
#include <furi.h>
-#include <flipper_file/flipper_file.h>
+#include <flipper_format/flipper_format.h>
+#include <flipper_format/flipper_format_i.h>
+#include <toolbox/stream/stream.h>
#include "../minunit.h"
#define TEST_DIR TEST_DIR_NAME "/"
@@ -28,8 +30,8 @@ static const char* test_hex_key = "Hex data";
static const uint8_t test_hex_data[] = {0xDE, 0xAD, 0xBE};
static const uint8_t test_hex_updated_data[] = {0xFE, 0xCA};
-#define READ_TEST_WIN "ff_win.test"
-static const char* test_data_win = "Filetype: Flipper File test\n"
+#define READ_TEST_NIX "ff_nix.test"
+static const char* test_data_nix = "Filetype: Flipper File test\n"
"Version: 666\n"
"# This is comment\n"
"String data: String\n"
@@ -38,8 +40,8 @@ static const char* test_data_win = "Filetype: Flipper File test\n"
"Float data: 1.5 1000.0\n"
"Hex data: DE AD BE";
-#define READ_TEST_NIX "ff_nix.test"
-static const char* test_data_nix = "Filetype: Flipper File test\r\n"
+#define READ_TEST_WIN "ff_win.test"
+static const char* test_data_win = "Filetype: Flipper File test\r\n"
"Version: 666\r\n"
"# This is comment\r\n"
"String data: String\r\n"
@@ -51,11 +53,11 @@ static const char* test_data_nix = "Filetype: Flipper File test\r\n"
#define READ_TEST_FLP "ff_flp.test"
// data created by user on linux machine
-const char* test_file_linux = TEST_DIR READ_TEST_WIN;
+static const char* test_file_linux = TEST_DIR READ_TEST_NIX;
// data created by user on windows machine
-const char* test_file_windows = TEST_DIR READ_TEST_NIX;
+static const char* test_file_windows = TEST_DIR READ_TEST_WIN;
// data created by flipper itself
-const char* test_file_flipper = TEST_DIR READ_TEST_FLP;
+static const char* test_file_flipper = TEST_DIR READ_TEST_FLP;
static bool storage_write_string(const char* path, const char* data) {
Storage* storage = furi_record_open("storage");
@@ -93,43 +95,43 @@ static bool test_read(const char* file_name) {
Storage* storage = furi_record_open("storage");
bool result = false;
- FlipperFile* file = flipper_file_alloc(storage);
+ FlipperFormat* file = flipper_format_file_alloc(storage);
string_t string_value;
string_init(string_value);
uint32_t uint32_value;
void* scratchpad = malloc(512);
do {
- if(!flipper_file_open_existing(file, file_name)) break;
+ if(!flipper_format_file_open_existing(file, file_name)) break;
- if(!flipper_file_read_header(file, string_value, &uint32_value)) break;
+ if(!flipper_format_read_header(file, string_value, &uint32_value)) break;
if(string_cmp_str(string_value, test_filetype) != 0) break;
if(uint32_value != test_version) break;
- if(!flipper_file_read_string(file, test_string_key, string_value)) break;
+ if(!flipper_format_read_string(file, test_string_key, string_value)) break;
if(string_cmp_str(string_value, test_string_data) != 0) break;
- if(!flipper_file_get_value_count(file, test_int_key, &uint32_value)) break;
+ if(!flipper_format_get_value_count(file, test_int_key, &uint32_value)) break;
if(uint32_value != COUNT_OF(test_int_data)) break;
- if(!flipper_file_read_int32(file, test_int_key, scratchpad, uint32_value)) break;
+ if(!flipper_format_read_int32(file, test_int_key, scratchpad, uint32_value)) break;
if(memcmp(scratchpad, test_int_data, sizeof(int32_t) * COUNT_OF(test_int_data)) != 0)
break;
- if(!flipper_file_get_value_count(file, test_uint_key, &uint32_value)) break;
+ if(!flipper_format_get_value_count(file, test_uint_key, &uint32_value)) break;
if(uint32_value != COUNT_OF(test_uint_data)) break;
- if(!flipper_file_read_uint32(file, test_uint_key, scratchpad, uint32_value)) break;
+ if(!flipper_format_read_uint32(file, test_uint_key, scratchpad, uint32_value)) break;
if(memcmp(scratchpad, test_uint_data, sizeof(uint32_t) * COUNT_OF(test_uint_data)) != 0)
break;
- if(!flipper_file_get_value_count(file, test_float_key, &uint32_value)) break;
+ if(!flipper_format_get_value_count(file, test_float_key, &uint32_value)) break;
if(uint32_value != COUNT_OF(test_float_data)) break;
- if(!flipper_file_read_float(file, test_float_key, scratchpad, uint32_value)) break;
+ if(!flipper_format_read_float(file, test_float_key, scratchpad, uint32_value)) break;
if(memcmp(scratchpad, test_float_data, sizeof(float) * COUNT_OF(test_float_data)) != 0)
break;
- if(!flipper_file_get_value_count(file, test_hex_key, &uint32_value)) break;
+ if(!flipper_format_get_value_count(file, test_hex_key, &uint32_value)) break;
if(uint32_value != COUNT_OF(test_hex_data)) break;
- if(!flipper_file_read_hex(file, test_hex_key, scratchpad, uint32_value)) break;
+ if(!flipper_format_read_hex(file, test_hex_key, scratchpad, uint32_value)) break;
if(memcmp(scratchpad, test_hex_data, sizeof(uint8_t) * COUNT_OF(test_hex_data)) != 0)
break;
@@ -138,8 +140,8 @@ static bool test_read(const char* file_name) {
free(scratchpad);
string_clear(string_value);
- flipper_file_close(file);
- flipper_file_free(file);
+
+ flipper_format_free(file);
furi_record_close("storage");
@@ -150,52 +152,52 @@ static bool test_read_updated(const char* file_name) {
Storage* storage = furi_record_open("storage");
bool result = false;
- FlipperFile* file = flipper_file_alloc(storage);
+ FlipperFormat* file = flipper_format_file_alloc(storage);
string_t string_value;
string_init(string_value);
uint32_t uint32_value;
void* scratchpad = malloc(512);
do {
- if(!flipper_file_open_existing(file, file_name)) break;
+ if(!flipper_format_file_open_existing(file, file_name)) break;
- if(!flipper_file_read_header(file, string_value, &uint32_value)) break;
+ if(!flipper_format_read_header(file, string_value, &uint32_value)) break;
if(string_cmp_str(string_value, test_filetype) != 0) break;
if(uint32_value != test_version) break;
- if(!flipper_file_read_string(file, test_string_key, string_value)) break;
+ if(!flipper_format_read_string(file, test_string_key, string_value)) break;
if(string_cmp_str(string_value, test_string_updated_data) != 0) break;
- if(!flipper_file_get_value_count(file, test_int_key, &uint32_value)) break;
+ if(!flipper_format_get_value_count(file, test_int_key, &uint32_value)) break;
if(uint32_value != COUNT_OF(test_int_updated_data)) break;
- if(!flipper_file_read_int32(file, test_int_key, scratchpad, uint32_value)) break;
+ if(!flipper_format_read_int32(file, test_int_key, scratchpad, uint32_value)) break;
if(memcmp(
scratchpad,
test_int_updated_data,
sizeof(int32_t) * COUNT_OF(test_int_updated_data)) != 0)
break;
- if(!flipper_file_get_value_count(file, test_uint_key, &uint32_value)) break;
+ if(!flipper_format_get_value_count(file, test_uint_key, &uint32_value)) break;
if(uint32_value != COUNT_OF(test_uint_updated_data)) break;
- if(!flipper_file_read_uint32(file, test_uint_key, scratchpad, uint32_value)) break;
+ if(!flipper_format_read_uint32(file, test_uint_key, scratchpad, uint32_value)) break;
if(memcmp(
scratchpad,
test_uint_updated_data,
sizeof(uint32_t) * COUNT_OF(test_uint_updated_data)) != 0)
break;
- if(!flipper_file_get_value_count(file, test_float_key, &uint32_value)) break;
+ if(!flipper_format_get_value_count(file, test_float_key, &uint32_value)) break;
if(uint32_value != COUNT_OF(test_float_updated_data)) break;
- if(!flipper_file_read_float(file, test_float_key, scratchpad, uint32_value)) break;
+ if(!flipper_format_read_float(file, test_float_key, scratchpad, uint32_value)) break;
if(memcmp(
scratchpad,
test_float_updated_data,
sizeof(float) * COUNT_OF(test_float_updated_data)) != 0)
break;
- if(!flipper_file_get_value_count(file, test_hex_key, &uint32_value)) break;
+ if(!flipper_format_get_value_count(file, test_hex_key, &uint32_value)) break;
if(uint32_value != COUNT_OF(test_hex_updated_data)) break;
- if(!flipper_file_read_hex(file, test_hex_key, scratchpad, uint32_value)) break;
+ if(!flipper_format_read_hex(file, test_hex_key, scratchpad, uint32_value)) break;
if(memcmp(
scratchpad,
test_hex_updated_data,
@@ -207,8 +209,8 @@ static bool test_read_updated(const char* file_name) {
free(scratchpad);
string_clear(string_value);
- flipper_file_close(file);
- flipper_file_free(file);
+
+ flipper_format_free(file);
furi_record_close("storage");
@@ -218,28 +220,27 @@ static bool test_read_updated(const char* file_name) {
static bool test_write(const char* file_name) {
Storage* storage = furi_record_open("storage");
bool result = false;
- FlipperFile* file = flipper_file_alloc(storage);
+ FlipperFormat* file = flipper_format_file_alloc(storage);
do {
- if(!flipper_file_open_always(file, file_name)) break;
- if(!flipper_file_write_header_cstr(file, test_filetype, test_version)) break;
- if(!flipper_file_write_comment_cstr(file, "This is comment")) break;
- if(!flipper_file_write_string_cstr(file, test_string_key, test_string_data)) break;
- if(!flipper_file_write_int32(file, test_int_key, test_int_data, COUNT_OF(test_int_data)))
+ if(!flipper_format_file_open_always(file, file_name)) break;
+ if(!flipper_format_write_header_cstr(file, test_filetype, test_version)) break;
+ if(!flipper_format_write_comment_cstr(file, "This is comment")) break;
+ if(!flipper_format_write_string_cstr(file, test_string_key, test_string_data)) break;
+ if(!flipper_format_write_int32(file, test_int_key, test_int_data, COUNT_OF(test_int_data)))
break;
- if(!flipper_file_write_uint32(
+ if(!flipper_format_write_uint32(
file, test_uint_key, test_uint_data, COUNT_OF(test_uint_data)))
break;
- if(!flipper_file_write_float(
+ if(!flipper_format_write_float(
file, test_float_key, test_float_data, COUNT_OF(test_float_data)))
break;
- if(!flipper_file_write_hex(file, test_hex_key, test_hex_data, COUNT_OF(test_hex_data)))
+ if(!flipper_format_write_hex(file, test_hex_key, test_hex_data, COUNT_OF(test_hex_data)))
break;
result = true;
} while(false);
- flipper_file_close(file);
- flipper_file_free(file);
+ flipper_format_free(file);
furi_record_close("storage");
return result;
@@ -248,16 +249,15 @@ static bool test_write(const char* file_name) {
static bool test_delete_last_key(const char* file_name) {
Storage* storage = furi_record_open("storage");
bool result = false;
- FlipperFile* file = flipper_file_alloc(storage);
+ FlipperFormat* file = flipper_format_file_alloc(storage);
do {
- if(!flipper_file_open_existing(file, file_name)) break;
- if(!flipper_file_delete_key(file, test_hex_key)) break;
+ if(!flipper_format_file_open_existing(file, file_name)) break;
+ if(!flipper_format_delete_key(file, test_hex_key)) break;
result = true;
} while(false);
- flipper_file_close(file);
- flipper_file_free(file);
+ flipper_format_free(file);
furi_record_close("storage");
return result;
@@ -266,17 +266,16 @@ static bool test_delete_last_key(const char* file_name) {
static bool test_append_key(const char* file_name) {
Storage* storage = furi_record_open("storage");
bool result = false;
- FlipperFile* file = flipper_file_alloc(storage);
+ FlipperFormat* file = flipper_format_file_alloc(storage);
do {
- if(!flipper_file_open_append(file, file_name)) break;
- if(!flipper_file_write_hex(file, test_hex_key, test_hex_data, COUNT_OF(test_hex_data)))
+ if(!flipper_format_file_open_append(file, file_name)) break;
+ if(!flipper_format_write_hex(file, test_hex_key, test_hex_data, COUNT_OF(test_hex_data)))
break;
result = true;
} while(false);
- flipper_file_close(file);
- flipper_file_free(file);
+ flipper_format_free(file);
furi_record_close("storage");
return result;
@@ -285,30 +284,29 @@ static bool test_append_key(const char* file_name) {
static bool test_update(const char* file_name) {
Storage* storage = furi_record_open("storage");
bool result = false;
- FlipperFile* file = flipper_file_alloc(storage);
+ FlipperFormat* file = flipper_format_file_alloc(storage);
do {
- if(!flipper_file_open_existing(file, file_name)) break;
- if(!flipper_file_update_string_cstr(file, test_string_key, test_string_updated_data))
+ if(!flipper_format_file_open_existing(file, file_name)) break;
+ if(!flipper_format_update_string_cstr(file, test_string_key, test_string_updated_data))
break;
- if(!flipper_file_update_int32(
+ if(!flipper_format_update_int32(
file, test_int_key, test_int_updated_data, COUNT_OF(test_int_updated_data)))
break;
- if(!flipper_file_update_uint32(
+ if(!flipper_format_update_uint32(
file, test_uint_key, test_uint_updated_data, COUNT_OF(test_uint_updated_data)))
break;
- if(!flipper_file_update_float(
+ if(!flipper_format_update_float(
file, test_float_key, test_float_updated_data, COUNT_OF(test_float_updated_data)))
break;
- if(!flipper_file_update_hex(
+ if(!flipper_format_update_hex(
file, test_hex_key, test_hex_updated_data, COUNT_OF(test_hex_updated_data)))
break;
result = true;
} while(false);
- flipper_file_close(file);
- flipper_file_free(file);
+ flipper_format_free(file);
furi_record_close("storage");
return result;
@@ -317,27 +315,26 @@ static bool test_update(const char* file_name) {
static bool test_update_backward(const char* file_name) {
Storage* storage = furi_record_open("storage");
bool result = false;
- FlipperFile* file = flipper_file_alloc(storage);
+ FlipperFormat* file = flipper_format_file_alloc(storage);
do {
- if(!flipper_file_open_existing(file, file_name)) break;
- if(!flipper_file_update_string_cstr(file, test_string_key, test_string_data)) break;
- if(!flipper_file_update_int32(file, test_int_key, test_int_data, COUNT_OF(test_int_data)))
+ if(!flipper_format_file_open_existing(file, file_name)) break;
+ if(!flipper_format_update_string_cstr(file, test_string_key, test_string_data)) break;
+ if(!flipper_format_update_int32(file, test_int_key, test_int_data, COUNT_OF(test_int_data)))
break;
- if(!flipper_file_update_uint32(
+ if(!flipper_format_update_uint32(
file, test_uint_key, test_uint_data, COUNT_OF(test_uint_data)))
break;
- if(!flipper_file_update_float(
+ if(!flipper_format_update_float(
file, test_float_key, test_float_data, COUNT_OF(test_float_data)))
break;
- if(!flipper_file_update_hex(file, test_hex_key, test_hex_data, COUNT_OF(test_hex_data)))
+ if(!flipper_format_update_hex(file, test_hex_key, test_hex_data, COUNT_OF(test_hex_data)))
break;
result = true;
} while(false);
- flipper_file_close(file);
- flipper_file_free(file);
+ flipper_format_free(file);
furi_record_close("storage");
return result;
@@ -346,15 +343,15 @@ static bool test_update_backward(const char* file_name) {
static bool test_write_multikey(const char* file_name) {
Storage* storage = furi_record_open("storage");
bool result = false;
- FlipperFile* file = flipper_file_alloc(storage);
+ FlipperFormat* file = flipper_format_file_alloc(storage);
do {
- if(!flipper_file_open_always(file, file_name)) break;
- if(!flipper_file_write_header_cstr(file, test_filetype, test_version)) break;
+ if(!flipper_format_file_open_always(file, file_name)) break;
+ if(!flipper_format_write_header_cstr(file, test_filetype, test_version)) break;
bool error = false;
for(uint8_t index = 0; index < 100; index++) {
- if(!flipper_file_write_hex(file, test_hex_key, &index, 1)) {
+ if(!flipper_format_write_hex(file, test_hex_key, &index, 1)) {
error = true;
break;
}
@@ -364,8 +361,7 @@ static bool test_write_multikey(const char* file_name) {
result = true;
} while(false);
- flipper_file_close(file);
- flipper_file_free(file);
+ flipper_format_free(file);
furi_record_close("storage");
return result;
@@ -374,22 +370,22 @@ static bool test_write_multikey(const char* file_name) {
static bool test_read_multikey(const char* file_name) {
Storage* storage = furi_record_open("storage");
bool result = false;
- FlipperFile* file = flipper_file_alloc(storage);
+ FlipperFormat* file = flipper_format_file_alloc(storage);
string_t string_value;
string_init(string_value);
uint32_t uint32_value;
do {
- if(!flipper_file_open_existing(file, file_name)) break;
- if(!flipper_file_read_header(file, string_value, &uint32_value)) break;
+ if(!flipper_format_file_open_existing(file, file_name)) break;
+ if(!flipper_format_read_header(file, string_value, &uint32_value)) break;
if(string_cmp_str(string_value, test_filetype) != 0) break;
if(uint32_value != test_version) break;
bool error = false;
uint8_t uint8_value;
for(uint8_t index = 0; index < 100; index++) {
- if(!flipper_file_read_hex(file, test_hex_key, &uint8_value, 1)) {
+ if(!flipper_format_read_hex(file, test_hex_key, &uint8_value, 1)) {
error = true;
break;
}
@@ -405,96 +401,96 @@ static bool test_read_multikey(const char* file_name) {
} while(false);
string_clear(string_value);
- flipper_file_close(file);
- flipper_file_free(file);
+
+ flipper_format_free(file);
furi_record_close("storage");
return result;
}
-MU_TEST(flipper_file_write_test) {
+MU_TEST(flipper_format_write_test) {
mu_assert(storage_write_string(test_file_linux, test_data_nix), "Write test error [Linux]");
mu_assert(
storage_write_string(test_file_windows, test_data_win), "Write test error [Windows]");
mu_assert(test_write(test_file_flipper), "Write test error [Flipper]");
}
-MU_TEST(flipper_file_read_test) {
+MU_TEST(flipper_format_read_test) {
mu_assert(test_read(test_file_linux), "Read test error [Linux]");
mu_assert(test_read(test_file_windows), "Read test error [Windows]");
mu_assert(test_read(test_file_flipper), "Read test error [Flipper]");
}
-MU_TEST(flipper_file_delete_test) {
+MU_TEST(flipper_format_delete_test) {
mu_assert(test_delete_last_key(test_file_linux), "Cannot delete key [Linux]");
mu_assert(test_delete_last_key(test_file_windows), "Cannot delete key [Windows]");
mu_assert(test_delete_last_key(test_file_flipper), "Cannot delete key [Flipper]");
}
-MU_TEST(flipper_file_delete_result_test) {
+MU_TEST(flipper_format_delete_result_test) {
mu_assert(!test_read(test_file_linux), "Key deleted incorrectly [Linux]");
mu_assert(!test_read(test_file_windows), "Key deleted incorrectly [Windows]");
mu_assert(!test_read(test_file_flipper), "Key deleted incorrectly [Flipper]");
}
-MU_TEST(flipper_file_append_test) {
+MU_TEST(flipper_format_append_test) {
mu_assert(test_append_key(test_file_linux), "Cannot append data [Linux]");
mu_assert(test_append_key(test_file_windows), "Cannot append data [Windows]");
mu_assert(test_append_key(test_file_flipper), "Cannot append data [Flipper]");
}
-MU_TEST(flipper_file_append_result_test) {
+MU_TEST(flipper_format_append_result_test) {
mu_assert(test_read(test_file_linux), "Data appended incorrectly [Linux]");
mu_assert(test_read(test_file_windows), "Data appended incorrectly [Windows]");
mu_assert(test_read(test_file_flipper), "Data appended incorrectly [Flipper]");
}
-MU_TEST(flipper_file_update_1_test) {
+MU_TEST(flipper_format_update_1_test) {
mu_assert(test_update(test_file_linux), "Cannot update data #1 [Linux]");
mu_assert(test_update(test_file_windows), "Cannot update data #1 [Windows]");
mu_assert(test_update(test_file_flipper), "Cannot update data #1 [Flipper]");
}
-MU_TEST(flipper_file_update_1_result_test) {
+MU_TEST(flipper_format_update_1_result_test) {
mu_assert(test_read_updated(test_file_linux), "Data #1 updated incorrectly [Linux]");
mu_assert(test_read_updated(test_file_windows), "Data #1 updated incorrectly [Windows]");
mu_assert(test_read_updated(test_file_flipper), "Data #1 updated incorrectly [Flipper]");
}
-MU_TEST(flipper_file_update_2_test) {
+MU_TEST(flipper_format_update_2_test) {
mu_assert(test_update_backward(test_file_linux), "Cannot update data #2 [Linux]");
mu_assert(test_update_backward(test_file_windows), "Cannot update data #2 [Windows]");
mu_assert(test_update_backward(test_file_flipper), "Cannot update data #2 [Flipper]");
}
-MU_TEST(flipper_file_update_2_result_test) {
+MU_TEST(flipper_format_update_2_result_test) {
mu_assert(test_read(test_file_linux), "Data #2 updated incorrectly [Linux]");
mu_assert(test_read(test_file_windows), "Data #2 updated incorrectly [Windows]");
mu_assert(test_read(test_file_flipper), "Data #2 updated incorrectly [Flipper]");
}
-MU_TEST(flipper_file_multikey_test) {
+MU_TEST(flipper_format_multikey_test) {
mu_assert(test_write_multikey(TEST_DIR "ff_multiline.test"), "Multikey write test error");
mu_assert(test_read_multikey(TEST_DIR "ff_multiline.test"), "Multikey read test error");
}
-MU_TEST_SUITE(flipper_file) {
+MU_TEST_SUITE(flipper_format) {
tests_setup();
- MU_RUN_TEST(flipper_file_write_test);
- MU_RUN_TEST(flipper_file_read_test);
- MU_RUN_TEST(flipper_file_delete_test);
- MU_RUN_TEST(flipper_file_delete_result_test);
- MU_RUN_TEST(flipper_file_append_test);
- MU_RUN_TEST(flipper_file_append_result_test);
- MU_RUN_TEST(flipper_file_update_1_test);
- MU_RUN_TEST(flipper_file_update_1_result_test);
- MU_RUN_TEST(flipper_file_update_2_test);
- MU_RUN_TEST(flipper_file_update_2_result_test);
- MU_RUN_TEST(flipper_file_multikey_test);
+ MU_RUN_TEST(flipper_format_write_test);
+ MU_RUN_TEST(flipper_format_read_test);
+ MU_RUN_TEST(flipper_format_delete_test);
+ MU_RUN_TEST(flipper_format_delete_result_test);
+ MU_RUN_TEST(flipper_format_append_test);
+ MU_RUN_TEST(flipper_format_append_result_test);
+ MU_RUN_TEST(flipper_format_update_1_test);
+ MU_RUN_TEST(flipper_format_update_1_result_test);
+ MU_RUN_TEST(flipper_format_update_2_test);
+ MU_RUN_TEST(flipper_format_update_2_result_test);
+ MU_RUN_TEST(flipper_format_multikey_test);
tests_teardown();
}
-int run_minunit_test_flipper_file() {
- MU_RUN_SUITE(flipper_file);
+int run_minunit_test_flipper_format() {
+ MU_RUN_SUITE(flipper_format);
return MU_EXIT_CODE;
-} \ No newline at end of file
+}
diff --git a/applications/tests/furi_memmgr_test.c b/applications/tests/furi_memmgr_test.c
index 99925be8..732856ec 100644
--- a/applications/tests/furi_memmgr_test.c
+++ b/applications/tests/furi_memmgr_test.c
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
+
// this test is not accurate, but gives a basic understanding
// that memory management is working fine
@@ -96,4 +97,4 @@ void test_furi_memmgr() {
free(original_ptr);
free(ptr);
-} \ No newline at end of file
+}
diff --git a/applications/tests/irda_decoder_encoder/irda_decoder_encoder_test.c b/applications/tests/irda_decoder_encoder/irda_decoder_encoder_test.c
index 3e2a6831..7ab27430 100644
--- a/applications/tests/irda_decoder_encoder/irda_decoder_encoder_test.c
+++ b/applications/tests/irda_decoder_encoder/irda_decoder_encoder_test.c
@@ -88,7 +88,7 @@ static void run_encoder(
uint32_t* timings = 0;
uint32_t timings_len = 200;
uint32_t j = 0;
- timings = furi_alloc(sizeof(uint32_t) * timings_len);
+ timings = malloc(sizeof(uint32_t) * timings_len);
for(uint32_t message_counter = 0; message_counter < input_messages_len; ++message_counter) {
const IrdaMessage* message = &input_messages[message_counter];
@@ -113,7 +113,7 @@ static void run_encoder_decoder(const IrdaMessage input_messages[], uint32_t inp
uint32_t* timings = 0;
uint32_t timings_len = 200;
bool level = false;
- timings = furi_alloc(sizeof(uint32_t) * timings_len);
+ timings = malloc(sizeof(uint32_t) * timings_len);
for(uint32_t message_counter = 0; message_counter < input_messages_len; ++message_counter) {
const IrdaMessage* message_encoded = &input_messages[message_counter];
diff --git a/applications/tests/minunit.h b/applications/tests/minunit.h
index b12a87ca..d1efd13e 100644
--- a/applications/tests/minunit.h
+++ b/applications/tests/minunit.h
@@ -84,6 +84,7 @@ void minunit_print_fail(const char* error);
/* Definitions */
#define MU_TEST(method_name) static void method_name(void)
+#define MU_TEST_1(method_name, arg_1) static void method_name(arg_1)
#define MU_TEST_SUITE(suite_name) static void suite_name(void)
#define MU__SAFE_BLOCK(block) \
@@ -107,11 +108,30 @@ void minunit_print_fail(const char* error);
minunit_proc_timer = mu_timer_cpu(); \
} if(minunit_setup) (*minunit_setup)(); \
minunit_status = 0; \
+ printf(#test "()\r\n"); \
test(); \
minunit_run++; \
if(minunit_status) { \
minunit_fail++; \
minunit_print_fail(minunit_last_message); \
+ minunit_status = 0; \
+ } fflush(stdout); \
+ if(minunit_teardown)(*minunit_teardown)();)
+
+#define MU_RUN_TEST_1(test, arg_1) \
+ MU__SAFE_BLOCK( \
+ if(minunit_real_timer == 0 && minunit_proc_timer == 0) { \
+ minunit_real_timer = mu_timer_real(); \
+ minunit_proc_timer = mu_timer_cpu(); \
+ } if(minunit_setup) (*minunit_setup)(); \
+ minunit_status = 0; \
+ printf(#test "(" #arg_1 ")\r\n"); \
+ test(arg_1); \
+ minunit_run++; \
+ if(minunit_status) { \
+ minunit_fail++; \
+ minunit_print_fail(minunit_last_message); \
+ minunit_status = 0; \
} fflush(stdout); \
if(minunit_teardown)(*minunit_teardown)();)
diff --git a/applications/tests/rpc/rpc_test.c b/applications/tests/rpc/rpc_test.c
index ccd8ea78..b51a1278 100644
--- a/applications/tests/rpc/rpc_test.c
+++ b/applications/tests/rpc/rpc_test.c
@@ -136,9 +136,9 @@ static void clean_directory(Storage* fs_api, const char* clean_dir) {
File* dir = storage_file_alloc(fs_api);
if(storage_dir_open(dir, clean_dir)) {
FileInfo fileinfo;
- char* name = furi_alloc(MAX_NAME_LENGTH + 1);
+ char* name = malloc(MAX_NAME_LENGTH + 1);
while(storage_dir_read(dir, &fileinfo, name, MAX_NAME_LENGTH)) {
- char* fullname = furi_alloc(strlen(clean_dir) + strlen(name) + 1 + 1);
+ char* fullname = malloc(strlen(clean_dir) + strlen(name) + 1 + 1);
sprintf(fullname, "%s/%s", clean_dir, name);
if(fileinfo.flags & FSF_DIRECTORY) {
clean_directory(fs_api, fullname);
@@ -310,7 +310,7 @@ static void test_rpc_add_read_or_write_to_list(
msg_file = &request->content.storage_read_response.file;
}
- msg_file->data = furi_alloc(PB_BYTES_ARRAY_T_ALLOCSIZE(pattern_size));
+ msg_file->data = malloc(PB_BYTES_ARRAY_T_ALLOCSIZE(pattern_size));
msg_file->data->size = pattern_size;
memcpy(msg_file->data->bytes, pattern, pattern_size);
@@ -328,7 +328,7 @@ static void test_rpc_encode_and_feed_one(PB_Main* request) {
bool result = pb_encode_ex(&ostream, &PB_Main_msg, request, PB_ENCODE_DELIMITED);
furi_check(result && ostream.bytes_written);
- uint8_t* buffer = furi_alloc(ostream.bytes_written);
+ uint8_t* buffer = malloc(ostream.bytes_written);
ostream = pb_ostream_from_buffer(buffer, ostream.bytes_written);
pb_encode_ex(&ostream, &PB_Main_msg, request, PB_ENCODE_DELIMITED);
@@ -501,13 +501,13 @@ static void
message->content.storage_list_response.file[1].type = PB_Storage_File_FileType_DIR;
message->content.storage_list_response.file[2].type = PB_Storage_File_FileType_DIR;
- char* str = furi_alloc(4);
+ char* str = malloc(4);
strcpy(str, "any");
message->content.storage_list_response.file[0].name = str;
- str = furi_alloc(4);
+ str = malloc(4);
strcpy(str, "int");
message->content.storage_list_response.file[1].name = str;
- str = furi_alloc(4);
+ str = malloc(4);
strcpy(str, "ext");
message->content.storage_list_response.file[2].name = str;
}
@@ -540,7 +540,7 @@ static void test_rpc_storage_list_create_expected_list(
while(!finish) {
FileInfo fileinfo;
- char* name = furi_alloc(MAX_NAME_LENGTH + 1);
+ char* name = malloc(MAX_NAME_LENGTH + 1);
if(storage_dir_read(dir, &fileinfo, name, MAX_NAME_LENGTH)) {
if(i == COUNT_OF(list->file)) {
list->file_count = i;
@@ -675,7 +675,7 @@ static void test_rpc_add_read_to_list_by_reading_real_file(
response->content.storage_read_response.has_file = true;
response->content.storage_read_response.file.data =
- furi_alloc(PB_BYTES_ARRAY_T_ALLOCSIZE(MIN(size_left, MAX_DATA_SIZE)));
+ malloc(PB_BYTES_ARRAY_T_ALLOCSIZE(MIN(size_left, MAX_DATA_SIZE)));
uint8_t* buffer = response->content.storage_read_response.file.data->bytes;
uint16_t* read_size_msg = &response->content.storage_read_response.file.data->size;
size_t read_size = MIN(size_left, MAX_DATA_SIZE);
@@ -873,7 +873,7 @@ static void test_storage_write_run(
MsgList_t expected_msg_list;
MsgList_init(expected_msg_list);
- uint8_t* buf = furi_alloc(write_size);
+ uint8_t* buf = malloc(write_size);
for(int i = 0; i < write_size; ++i) {
buf[i] = '0' + (i % 10);
}
@@ -1497,7 +1497,7 @@ MU_TEST_SUITE(test_rpc_app) {
static void
test_send_rubbish(RpcSession* session, const char* pattern, size_t pattern_size, size_t size) {
- uint8_t* buf = furi_alloc(size);
+ uint8_t* buf = malloc(size);
for(int i = 0; i < size; ++i) {
buf[i] = pattern[i % pattern_size];
}
diff --git a/applications/tests/stream/stream_test.c b/applications/tests/stream/stream_test.c
new file mode 100644
index 00000000..eed8a7bc
--- /dev/null
+++ b/applications/tests/stream/stream_test.c
@@ -0,0 +1,381 @@
+#include <furi.h>
+#include <toolbox/stream/stream.h>
+#include <toolbox/stream/string_stream.h>
+#include <toolbox/stream/file_stream.h>
+#include <storage/storage.h>
+#include "../minunit.h"
+
+static const char* stream_test_data = "I write differently from what I speak, "
+ "I speak differently from what I think, "
+ "I think differently from the way I ought to think, "
+ "and so it all proceeds into deepest darkness.";
+
+static const char* stream_test_left_data = "There are two cardinal human sins ";
+static const char* stream_test_right_data =
+ "from which all others derive: impatience and indolence.";
+
+MU_TEST_1(stream_composite_subtest, Stream* stream) {
+ const size_t data_size = 128;
+ uint8_t data[data_size];
+ string_t string_lee;
+ string_init_set(string_lee, "lee");
+
+ // test that stream is empty
+ // "" -> ""
+ mu_check(stream_size(stream) == 0);
+ mu_check(stream_eof(stream));
+ mu_check(stream_tell(stream) == 0);
+ mu_check(stream_read(stream, data, data_size) == 0);
+ mu_check(stream_eof(stream));
+ mu_check(stream_tell(stream) == 0);
+
+ // write char
+ // "" -> "2"
+ mu_check(stream_write_char(stream, '2') == 1);
+ mu_check(stream_size(stream) == 1);
+ mu_check(stream_tell(stream) == 1);
+ mu_check(stream_eof(stream));
+
+ // test rewind and eof
+ stream_rewind(stream);
+ mu_check(stream_size(stream) == 1);
+ mu_check(stream_tell(stream) == 0);
+ mu_check(!stream_eof(stream));
+
+ // add another char with replacement
+ // "2" -> "1"
+ mu_check(stream_write_char(stream, '1') == 1);
+ mu_check(stream_size(stream) == 1);
+ mu_check(stream_tell(stream) == 1);
+ mu_check(stream_eof(stream));
+
+ // write string
+ // "1" -> "1337_69"
+ mu_check(stream_write_cstring(stream, "337_69") == 6);
+ mu_check(stream_size(stream) == 7);
+ mu_check(stream_tell(stream) == 7);
+ mu_check(stream_eof(stream));
+
+ // read data
+ memset(data, 0, data_size);
+ stream_rewind(stream);
+ mu_check(stream_read(stream, data, data_size) == 7);
+ mu_check(strcmp((char*)data, "1337_69") == 0);
+
+ // test misc seeks
+ mu_check(stream_seek(stream, 2, StreamOffsetFromStart));
+ mu_check(stream_tell(stream) == 2);
+ mu_check(!stream_seek(stream, 9000, StreamOffsetFromStart));
+ mu_check(stream_tell(stream) == 7);
+ mu_check(stream_eof(stream));
+ mu_check(stream_seek(stream, -3, StreamOffsetFromEnd));
+ mu_check(stream_tell(stream) == 4);
+
+ // write string with replacemet
+ // "1337_69" -> "1337lee"
+ mu_check(stream_write_string(stream, string_lee) == 3);
+ mu_check(stream_size(stream) == 7);
+ mu_check(stream_tell(stream) == 7);
+ mu_check(stream_eof(stream));
+
+ // append char
+ // "1337lee" -> "1337leet"
+ mu_check(stream_write(stream, (uint8_t*)"t", 1) == 1);
+ mu_check(stream_size(stream) == 8);
+ mu_check(stream_tell(stream) == 8);
+ mu_check(stream_eof(stream));
+
+ // read data
+ memset(data, 0, data_size);
+ stream_rewind(stream);
+ mu_check(stream_read(stream, data, data_size) == 8);
+ mu_check(strcmp((char*)data, "1337leet") == 0);
+ mu_check(stream_tell(stream) == 8);
+ mu_check(stream_eof(stream));
+
+ // negative seek from current position -> clamp to 0
+ mu_check(!stream_seek(stream, -9000, StreamOffsetFromCurrent));
+ mu_check(stream_tell(stream) == 0);
+
+ // negative seek from start position -> clamp to 0
+ stream_rewind(stream);
+ mu_check(!stream_seek(stream, -3, StreamOffsetFromStart));
+ mu_check(stream_tell(stream) == 0);
+
+ // zero seek from current position -> clamp to stream size
+ mu_check(stream_seek(stream, 0, StreamOffsetFromEnd));
+ mu_check(stream_tell(stream) == 8);
+
+ // negative seek from end position -> clamp to 0
+ mu_check(!stream_seek(stream, -9000, StreamOffsetFromEnd));
+ mu_check(stream_tell(stream) == 0);
+
+ // clean stream
+ stream_clean(stream);
+ mu_check(stream_size(stream) == 0);
+ mu_check(stream_eof(stream));
+ mu_check(stream_tell(stream) == 0);
+
+ // write format
+ // "" -> "dio666"
+ mu_check(stream_write_format(stream, "%s%d", "dio", 666) == 6);
+ mu_check(stream_size(stream) == 6);
+ mu_check(stream_eof(stream));
+ mu_check(stream_tell(stream) == 6);
+
+ // read data
+ memset(data, 0, data_size);
+ stream_rewind(stream);
+ mu_check(stream_read(stream, data, data_size) == 6);
+ mu_check(strcmp((char*)data, "dio666") == 0);
+
+ // clean and write cstring
+ // "dio666" -> "" -> "1234567890"
+ stream_clean(stream);
+ mu_check(stream_write_cstring(stream, "1234567890") == 10);
+
+ // delete 4 bytes from 1 pos
+ // "1xxxx67890" -> "167890"
+ mu_check(stream_seek(stream, 1, StreamOffsetFromStart));
+ mu_check(stream_delete(stream, 4));
+ mu_assert_int_eq(6, stream_size(stream));
+
+ // read data
+ memset(data, 0, data_size);
+ stream_rewind(stream);
+ mu_assert_int_eq(6, stream_read(stream, data, data_size));
+ mu_check(strcmp((char*)data, "167890") == 0);
+
+ // write cstring
+ // "167890" -> "167890It Was Me, Dio!"
+ mu_check(stream_write_cstring(stream, "It Was Me, Dio!") == 15);
+
+ // delete 1337 bytes from 1 pos
+ // and check that we can delete only 20 bytes
+ // "1xxxxxxxxxxxxxxxxxxxx" -> "1"
+ mu_check(stream_seek(stream, 1, StreamOffsetFromStart));
+ mu_check(stream_delete(stream, 1337));
+ mu_assert_int_eq(1, stream_size(stream));
+
+ // read data
+ memset(data, 0, data_size);
+ stream_rewind(stream);
+ mu_check(stream_read(stream, data, data_size) == 1);
+ mu_check(strcmp((char*)data, "1") == 0);
+
+ // write cstring from 0 pos, replacing 1 byte
+ // "1" -> "Oh? You're roaching me?"
+ mu_check(stream_rewind(stream));
+ mu_assert_int_eq(23, stream_write_cstring(stream, "Oh? You're roaching me?"));
+
+ // insert 11 bytes to 0 pos
+ // "Oh? You're roaching me?" -> "Za Warudo! Oh? You're roaching me?"
+ mu_check(stream_rewind(stream));
+ mu_check(stream_insert(stream, (uint8_t*)"Za Warudo! ", 11));
+ mu_assert_int_eq(34, stream_size(stream));
+
+ // read data
+ memset(data, 0, data_size);
+ stream_rewind(stream);
+ mu_assert_int_eq(34, stream_read(stream, data, data_size));
+ mu_assert_string_eq("Za Warudo! Oh? You're roaching me?", (char*)data);
+
+ // insert cstring to 22 pos
+ // "Za Warudo! Oh? You're roaching me?" -> "Za Warudo! Oh? You're approaching me?"
+ mu_check(stream_seek(stream, 22, StreamOffsetFromStart));
+ mu_check(stream_insert_cstring(stream, "app"));
+ mu_assert_int_eq(37, stream_size(stream));
+
+ // read data
+ memset(data, 0, data_size);
+ stream_rewind(stream);
+ mu_assert_int_eq(37, stream_read(stream, data, data_size));
+ mu_assert_string_eq("Za Warudo! Oh? You're approaching me?", (char*)data);
+
+ // insert cstring to the end of the stream
+ // "Za Warudo! Oh? You're approaching me?" -> "Za Warudo! Oh? You're approaching me? It was me, Dio!"
+ mu_check(stream_seek(stream, 0, StreamOffsetFromEnd));
+ mu_check(stream_insert_cstring(stream, " It was me, Dio!"));
+ mu_assert_int_eq(53, stream_size(stream));
+
+ // read data
+ memset(data, 0, data_size);
+ stream_rewind(stream);
+ mu_assert_int_eq(53, stream_read(stream, data, data_size));
+ mu_assert_string_eq("Za Warudo! Oh? You're approaching me? It was me, Dio!", (char*)data);
+
+ // delete 168430090 bytes from stream
+ // and test that we can delete only 53
+ mu_check(stream_rewind(stream));
+ mu_check(stream_delete(stream, 0x0A0A0A0A));
+ mu_assert_int_eq(0, stream_size(stream));
+ mu_check(stream_eof(stream));
+ mu_assert_int_eq(0, stream_tell(stream));
+
+ // clean stream
+ stream_clean(stream);
+ mu_assert_int_eq(0, stream_size(stream));
+ mu_check(stream_eof(stream));
+ mu_assert_int_eq(0, stream_tell(stream));
+
+ // insert formated string at the end of stream
+ // "" -> "dio666"
+ mu_check(stream_insert_format(stream, "%s%d", "dio", 666));
+ mu_assert_int_eq(6, stream_size(stream));
+ mu_check(stream_eof(stream));
+ mu_assert_int_eq(6, stream_tell(stream));
+
+ // insert formated string at the end of stream
+ // "dio666" -> "dio666zlo555"
+ mu_check(stream_insert_format(stream, "%s%d", "zlo", 555));
+ mu_assert_int_eq(12, stream_size(stream));
+ mu_check(stream_eof(stream));
+ mu_assert_int_eq(12, stream_tell(stream));
+
+ // insert formated string at the 6 pos
+ // "dio666" -> "dio666baba13zlo555"
+ mu_check(stream_seek(stream, 6, StreamOffsetFromStart));
+ mu_check(stream_insert_format(stream, "%s%d", "baba", 13));
+ mu_assert_int_eq(18, stream_size(stream));
+ mu_assert_int_eq(12, stream_tell(stream));
+
+ // read data
+ memset(data, 0, data_size);
+ stream_rewind(stream);
+ mu_assert_int_eq(18, stream_read(stream, data, data_size));
+ mu_assert_string_eq("dio666baba13zlo555", (char*)data);
+
+ // delete 6 chars from pos 6 and insert 1 chars
+ // "dio666baba13zlo555" -> "dio666xzlo555"
+ mu_check(stream_seek(stream, 6, StreamOffsetFromStart));
+ mu_check(stream_delete_and_insert_char(stream, 6, 'x'));
+ mu_assert_int_eq(13, stream_size(stream));
+ mu_assert_int_eq(7, stream_tell(stream));
+
+ // read data
+ memset(data, 0, data_size);
+ stream_rewind(stream);
+ mu_check(stream_read(stream, data, data_size) == 13);
+ mu_assert_string_eq("dio666xzlo555", (char*)data);
+
+ // delete 9000 chars from pos 6 and insert 3 chars from string
+ // "dio666xzlo555" -> "dio666777"
+ mu_check(stream_seek(stream, 6, StreamOffsetFromStart));
+ mu_check(stream_delete_and_insert_cstring(stream, 9000, "777"));
+ mu_assert_int_eq(9, stream_size(stream));
+ mu_assert_int_eq(9, stream_tell(stream));
+ mu_check(stream_eof(stream));
+
+ string_clear(string_lee);
+}
+
+MU_TEST(stream_composite_test) {
+ // test string stream
+ Stream* stream;
+ stream = string_stream_alloc();
+ MU_RUN_TEST_1(stream_composite_subtest, stream);
+ stream_free(stream);
+
+ // test file stream
+ Storage* storage = furi_record_open("storage");
+ stream = file_stream_alloc(storage);
+ mu_check(file_stream_open(stream, "/ext/filestream.str", FSAM_READ_WRITE, FSOM_CREATE_ALWAYS));
+ MU_RUN_TEST_1(stream_composite_subtest, stream);
+ stream_free(stream);
+ furi_record_close("storage");
+}
+
+MU_TEST_1(stream_write_subtest, Stream* stream) {
+ mu_assert_int_eq(strlen(stream_test_data), stream_write_cstring(stream, stream_test_data));
+}
+
+MU_TEST_1(stream_read_subtest, Stream* stream) {
+ uint8_t data[256] = {0};
+ mu_check(stream_rewind(stream));
+ mu_assert_int_eq(strlen(stream_test_data), stream_read(stream, data, 256));
+ mu_assert_string_eq(stream_test_data, (const char*)data);
+}
+
+MU_TEST(stream_write_read_save_load_test) {
+ Stream* stream_orig = string_stream_alloc();
+ Stream* stream_copy = string_stream_alloc();
+ Storage* storage = furi_record_open("storage");
+
+ // write, read
+ MU_RUN_TEST_1(stream_write_subtest, stream_orig);
+ MU_RUN_TEST_1(stream_read_subtest, stream_orig);
+
+ // copy, read
+ mu_assert_int_eq(strlen(stream_test_data), stream_copy_full(stream_orig, stream_copy));
+ MU_RUN_TEST_1(stream_read_subtest, stream_orig);
+
+ // save to file
+ mu_check(stream_seek(stream_orig, 0, StreamOffsetFromStart));
+ mu_assert_int_eq(
+ strlen(stream_test_data),
+ stream_save_to_file(stream_orig, storage, "/ext/filestream.str", FSOM_CREATE_ALWAYS));
+
+ stream_free(stream_copy);
+ stream_free(stream_orig);
+
+ // load from file, read
+ Stream* stream_new = string_stream_alloc();
+ mu_assert_int_eq(
+ strlen(stream_test_data),
+ stream_load_from_file(stream_new, storage, "/ext/filestream.str"));
+ MU_RUN_TEST_1(stream_read_subtest, stream_new);
+ stream_free(stream_new);
+
+ furi_record_close("storage");
+}
+
+MU_TEST_1(stream_split_subtest, Stream* stream) {
+ stream_clean(stream);
+ stream_write_cstring(stream, stream_test_left_data);
+ stream_write_cstring(stream, stream_test_right_data);
+
+ Stream* stream_left = string_stream_alloc();
+ Stream* stream_right = string_stream_alloc();
+
+ mu_check(stream_seek(stream, strlen(stream_test_left_data), StreamOffsetFromStart));
+ mu_check(stream_split(stream, stream_left, stream_right));
+
+ uint8_t data[256] = {0};
+ mu_check(stream_rewind(stream_left));
+ mu_assert_int_eq(strlen(stream_test_left_data), stream_read(stream_left, data, 256));
+ mu_assert_string_eq(stream_test_left_data, (const char*)data);
+
+ mu_check(stream_rewind(stream_right));
+ mu_assert_int_eq(strlen(stream_test_right_data), stream_read(stream_right, data, 256));
+ mu_assert_string_eq(stream_test_right_data, (const char*)data);
+
+ stream_free(stream_right);
+ stream_free(stream_left);
+}
+
+MU_TEST(stream_split_test) {
+ // test string stream
+ Stream* stream;
+ stream = string_stream_alloc();
+ MU_RUN_TEST_1(stream_split_subtest, stream);
+ stream_free(stream);
+
+ // test file stream
+ Storage* storage = furi_record_open("storage");
+ stream = file_stream_alloc(storage);
+ mu_check(file_stream_open(stream, "/ext/filestream.str", FSAM_READ_WRITE, FSOM_CREATE_ALWAYS));
+ MU_RUN_TEST_1(stream_split_subtest, stream);
+ stream_free(stream);
+ furi_record_close("storage");
+}
+
+MU_TEST_SUITE(stream_suite) {
+ MU_RUN_TEST(stream_write_read_save_load_test);
+ MU_RUN_TEST(stream_composite_test);
+ MU_RUN_TEST(stream_split_test);
+}
+
+int run_minunit_test_stream() {
+ MU_RUN_SUITE(stream_suite);
+ return MU_EXIT_CODE;
+} \ No newline at end of file
diff --git a/applications/tests/test_index.c b/applications/tests/test_index.c
index 3c70969f..6f934318 100644
--- a/applications/tests/test_index.c
+++ b/applications/tests/test_index.c
@@ -13,7 +13,9 @@
int run_minunit();
int run_minunit_test_irda_decoder_encoder();
int run_minunit_test_rpc();
-int run_minunit_test_flipper_file();
+int run_minunit_test_flipper_format();
+int run_minunit_test_flipper_format_string();
+int run_minunit_test_stream();
void minunit_print_progress(void) {
static char progress[] = {'\\', '|', '/', '-'};
@@ -27,7 +29,7 @@ void minunit_print_progress(void) {
}
void minunit_print_fail(const char* str) {
- printf("%s\n", str);
+ printf(FURI_LOG_CLR_E "%s\n" FURI_LOG_CLR_RESET, str);
}
void unit_tests_cli(Cli* cli, string_t args, void* context) {
@@ -53,7 +55,9 @@ void unit_tests_cli(Cli* cli, string_t args, void* context) {
test_result |= run_minunit();
test_result |= run_minunit_test_irda_decoder_encoder();
test_result |= run_minunit_test_rpc();
- test_result |= run_minunit_test_flipper_file();
+ test_result |= run_minunit_test_stream();
+ test_result |= run_minunit_test_flipper_format();
+ test_result |= run_minunit_test_flipper_format_string();
cycle_counter = (DWT->CYCCNT - cycle_counter);
FURI_LOG_I(TAG, "Consumed: %0.2fs", (float)cycle_counter / (SystemCoreClock));
diff --git a/applications/u2f/u2f.c b/applications/u2f/u2f.c
index 2a1286ef..051dca69 100644
--- a/applications/u2f/u2f.c
+++ b/applications/u2f/u2f.c
@@ -93,7 +93,7 @@ static int u2f_uecc_random(uint8_t* dest, unsigned size) {
}
U2fData* u2f_alloc() {
- return furi_alloc(sizeof(U2fData));
+ return malloc(sizeof(U2fData));
}
void u2f_free(U2fData* U2F) {
diff --git a/applications/u2f/u2f_app.c b/applications/u2f/u2f_app.c
index 9dde0f0d..88d86855 100644
--- a/applications/u2f/u2f_app.c
+++ b/applications/u2f/u2f_app.c
@@ -22,7 +22,7 @@ static void u2f_app_tick_event_callback(void* context) {
}
U2fApp* u2f_app_alloc() {
- U2fApp* app = furi_alloc(sizeof(U2fApp));
+ U2fApp* app = malloc(sizeof(U2fApp));
app->gui = furi_record_open("gui");
app->notifications = furi_record_open("notification");
diff --git a/applications/u2f/u2f_data.c b/applications/u2f/u2f_data.c
index e39eb95c..5143b27b 100644
--- a/applications/u2f/u2f_data.c
+++ b/applications/u2f/u2f_data.c
@@ -3,7 +3,7 @@
#include <furi_hal.h>
#include <storage/storage.h>
#include <furi_hal_random.h>
-#include <flipper_file.h>
+#include <flipper_format/flipper_format.h>
#define TAG "U2F"
@@ -147,22 +147,21 @@ static bool u2f_data_cert_key_encrypt(uint8_t* cert_key) {
furi_hal_crypto_store_unload_key(U2F_DATA_FILE_ENCRYPTION_KEY_SLOT_UNIQUE);
Storage* storage = furi_record_open("storage");
- FlipperFile* flipper_file = flipper_file_alloc(storage);
+ FlipperFormat* flipper_format = flipper_format_file_alloc(storage);
- if(flipper_file_open_always(flipper_file, U2F_CERT_KEY_FILE)) {
+ if(flipper_format_file_open_always(flipper_format, U2F_CERT_KEY_FILE)) {
do {
- if(!flipper_file_write_header_cstr(
- flipper_file, U2F_CERT_KEY_FILE_TYPE, U2F_CERT_KEY_VERSION))
+ if(!flipper_format_write_header_cstr(
+ flipper_format, U2F_CERT_KEY_FILE_TYPE, U2F_CERT_KEY_VERSION))
break;
- if(!flipper_file_write_uint32(flipper_file, "Type", &cert_type, 1)) break;
- if(!flipper_file_write_hex(flipper_file, "IV", iv, 16)) break;
- if(!flipper_file_write_hex(flipper_file, "Data", key, 48)) break;
+ if(!flipper_format_write_uint32(flipper_format, "Type", &cert_type, 1)) break;
+ if(!flipper_format_write_hex(flipper_format, "IV", iv, 16)) break;
+ if(!flipper_format_write_hex(flipper_format, "Data", key, 48)) break;
state = true;
} while(0);
}
- flipper_file_close(flipper_file);
- flipper_file_free(flipper_file);
+ flipper_format_free(flipper_format);
furi_record_close("storage");
return state;
@@ -185,11 +184,11 @@ bool u2f_data_cert_key_load(uint8_t* cert_key) {
string_init(filetype);
Storage* storage = furi_record_open("storage");
- FlipperFile* flipper_file = flipper_file_alloc(storage);
+ FlipperFormat* flipper_format = flipper_format_file_alloc(storage);
- if(flipper_file_open_existing(flipper_file, U2F_CERT_KEY_FILE)) {
+ if(flipper_format_file_open_existing(flipper_format, U2F_CERT_KEY_FILE)) {
do {
- if(!flipper_file_read_header(flipper_file, filetype, &version)) {
+ if(!flipper_format_read_header(flipper_format, filetype, &version)) {
FURI_LOG_E(TAG, "Missing or incorrect header");
break;
}
@@ -200,7 +199,7 @@ bool u2f_data_cert_key_load(uint8_t* cert_key) {
break;
}
- if(!flipper_file_read_uint32(flipper_file, "Type", &cert_type, 1)) {
+ if(!flipper_format_read_uint32(flipper_format, "Type", &cert_type, 1)) {
FURI_LOG_E(TAG, "Missing cert type");
break;
}
@@ -216,12 +215,12 @@ bool u2f_data_cert_key_load(uint8_t* cert_key) {
break;
}
if(key_slot != 0) {
- if(!flipper_file_read_hex(flipper_file, "IV", iv, 16)) {
+ if(!flipper_format_read_hex(flipper_format, "IV", iv, 16)) {
FURI_LOG_E(TAG, "Missing IV");
break;
}
- if(!flipper_file_read_hex(flipper_file, "Data", key, 48)) {
+ if(!flipper_format_read_hex(flipper_format, "Data", key, 48)) {
FURI_LOG_E(TAG, "Missing data");
break;
}
@@ -239,7 +238,7 @@ bool u2f_data_cert_key_load(uint8_t* cert_key) {
}
furi_hal_crypto_store_unload_key(key_slot);
} else {
- if(!flipper_file_read_hex(flipper_file, "Data", cert_key, 32)) {
+ if(!flipper_format_read_hex(flipper_format, "Data", cert_key, 32)) {
FURI_LOG_E(TAG, "Missing data");
break;
}
@@ -248,8 +247,7 @@ bool u2f_data_cert_key_load(uint8_t* cert_key) {
} while(0);
}
- flipper_file_close(flipper_file);
- flipper_file_free(flipper_file);
+ flipper_format_free(flipper_format);
furi_record_close("storage");
string_clear(filetype);
@@ -272,11 +270,11 @@ bool u2f_data_key_load(uint8_t* device_key) {
string_init(filetype);
Storage* storage = furi_record_open("storage");
- FlipperFile* flipper_file = flipper_file_alloc(storage);
+ FlipperFormat* flipper_format = flipper_format_file_alloc(storage);
- if(flipper_file_open_existing(flipper_file, U2F_KEY_FILE)) {
+ if(flipper_format_file_open_existing(flipper_format, U2F_KEY_FILE)) {
do {
- if(!flipper_file_read_header(flipper_file, filetype, &version)) {
+ if(!flipper_format_read_header(flipper_format, filetype, &version)) {
FURI_LOG_E(TAG, "Missing or incorrect header");
break;
}
@@ -285,11 +283,11 @@ bool u2f_data_key_load(uint8_t* device_key) {
FURI_LOG_E(TAG, "Type or version mismatch");
break;
}
- if(!flipper_file_read_hex(flipper_file, "IV", iv, 16)) {
+ if(!flipper_format_read_hex(flipper_format, "IV", iv, 16)) {
FURI_LOG_E(TAG, "Missing IV");
break;
}
- if(!flipper_file_read_hex(flipper_file, "Data", key, 48)) {
+ if(!flipper_format_read_hex(flipper_format, "Data", key, 48)) {
FURI_LOG_E(TAG, "Missing data");
break;
}
@@ -307,8 +305,7 @@ bool u2f_data_key_load(uint8_t* device_key) {
state = true;
} while(0);
}
- flipper_file_close(flipper_file);
- flipper_file_free(flipper_file);
+ flipper_format_free(flipper_format);
furi_record_close("storage");
string_clear(filetype);
return state;
@@ -338,22 +335,21 @@ bool u2f_data_key_generate(uint8_t* device_key) {
furi_hal_crypto_store_unload_key(U2F_DATA_FILE_ENCRYPTION_KEY_SLOT_UNIQUE);
Storage* storage = furi_record_open("storage");
- FlipperFile* flipper_file = flipper_file_alloc(storage);
+ FlipperFormat* flipper_format = flipper_format_file_alloc(storage);
- if(flipper_file_open_always(flipper_file, U2F_KEY_FILE)) {
+ if(flipper_format_file_open_always(flipper_format, U2F_KEY_FILE)) {
do {
- if(!flipper_file_write_header_cstr(
- flipper_file, U2F_DEVICE_KEY_FILE_TYPE, U2F_DEVICE_KEY_VERSION))
+ if(!flipper_format_write_header_cstr(
+ flipper_format, U2F_DEVICE_KEY_FILE_TYPE, U2F_DEVICE_KEY_VERSION))
break;
- if(!flipper_file_write_hex(flipper_file, "IV", iv, 16)) break;
- if(!flipper_file_write_hex(flipper_file, "Data", key_encrypted, 48)) break;
+ if(!flipper_format_write_hex(flipper_format, "IV", iv, 16)) break;
+ if(!flipper_format_write_hex(flipper_format, "Data", key_encrypted, 48)) break;
state = true;
memcpy(device_key, key, 32);
} while(0);
}
- flipper_file_close(flipper_file);
- flipper_file_free(flipper_file);
+ flipper_format_free(flipper_format);
furi_record_close("storage");
return state;
@@ -372,11 +368,11 @@ bool u2f_data_cnt_read(uint32_t* cnt_val) {
string_init(filetype);
Storage* storage = furi_record_open("storage");
- FlipperFile* flipper_file = flipper_file_alloc(storage);
+ FlipperFormat* flipper_format = flipper_format_file_alloc(storage);
- if(flipper_file_open_existing(flipper_file, U2F_CNT_FILE)) {
+ if(flipper_format_file_open_existing(flipper_format, U2F_CNT_FILE)) {
do {
- if(!flipper_file_read_header(flipper_file, filetype, &version)) {
+ if(!flipper_format_read_header(flipper_format, filetype, &version)) {
FURI_LOG_E(TAG, "Missing or incorrect header");
break;
}
@@ -385,11 +381,11 @@ bool u2f_data_cnt_read(uint32_t* cnt_val) {
FURI_LOG_E(TAG, "Type or version mismatch");
break;
}
- if(!flipper_file_read_hex(flipper_file, "IV", iv, 16)) {
+ if(!flipper_format_read_hex(flipper_format, "IV", iv, 16)) {
FURI_LOG_E(TAG, "Missing IV");
break;
}
- if(!flipper_file_read_hex(flipper_file, "Data", cnt_encr, 48)) {
+ if(!flipper_format_read_hex(flipper_format, "Data", cnt_encr, 48)) {
FURI_LOG_E(TAG, "Missing data");
break;
}
@@ -410,8 +406,7 @@ bool u2f_data_cnt_read(uint32_t* cnt_val) {
}
} while(0);
}
- flipper_file_close(flipper_file);
- flipper_file_free(flipper_file);
+ flipper_format_free(flipper_format);
furi_record_close("storage");
string_clear(filetype);
return state;
@@ -441,21 +436,20 @@ bool u2f_data_cnt_write(uint32_t cnt_val) {
furi_hal_crypto_store_unload_key(U2F_DATA_FILE_ENCRYPTION_KEY_SLOT_UNIQUE);
Storage* storage = furi_record_open("storage");
- FlipperFile* flipper_file = flipper_file_alloc(storage);
+ FlipperFormat* flipper_format = flipper_format_file_alloc(storage);
- if(flipper_file_open_always(flipper_file, U2F_CNT_FILE)) {
+ if(flipper_format_file_open_always(flipper_format, U2F_CNT_FILE)) {
do {
- if(!flipper_file_write_header_cstr(
- flipper_file, U2F_COUNTER_FILE_TYPE, U2F_COUNTER_VERSION))
+ if(!flipper_format_write_header_cstr(
+ flipper_format, U2F_COUNTER_FILE_TYPE, U2F_COUNTER_VERSION))
break;
- if(!flipper_file_write_hex(flipper_file, "IV", iv, 16)) break;
- if(!flipper_file_write_hex(flipper_file, "Data", cnt_encr, 48)) break;
+ if(!flipper_format_write_hex(flipper_format, "IV", iv, 16)) break;
+ if(!flipper_format_write_hex(flipper_format, "Data", cnt_encr, 48)) break;
state = true;
} while(0);
}
- flipper_file_close(flipper_file);
- flipper_file_free(flipper_file);
+ flipper_format_free(flipper_format);
furi_record_close("storage");
return state;
diff --git a/applications/u2f/u2f_hid.c b/applications/u2f/u2f_hid.c
index 1ddfecaf..ff1109fe 100644
--- a/applications/u2f/u2f_hid.c
+++ b/applications/u2f/u2f_hid.c
@@ -277,7 +277,7 @@ static int32_t u2f_hid_worker(void* context) {
}
U2fHid* u2f_hid_start(U2fData* u2f_inst) {
- U2fHid* u2f_hid = furi_alloc(sizeof(U2fHid));
+ U2fHid* u2f_hid = malloc(sizeof(U2fHid));
u2f_hid->u2f_instance = u2f_inst;
diff --git a/applications/u2f/views/u2f_view.c b/applications/u2f/views/u2f_view.c
index 8a6f441a..d04c656d 100644
--- a/applications/u2f/views/u2f_view.c
+++ b/applications/u2f/views/u2f_view.c
@@ -59,7 +59,7 @@ static bool u2f_view_input_callback(InputEvent* event, void* context) {
}
U2fView* u2f_view_alloc() {
- U2fView* u2f = furi_alloc(sizeof(U2fView));
+ U2fView* u2f = malloc(sizeof(U2fView));
u2f->view = view_alloc();
view_allocate_model(u2f->view, ViewModelTypeLocking, sizeof(U2fModel));