M*LIB: non-inlined strings, FuriString primitive (#1795)
* Quicksave 1 * Header stage complete * Source stage complete * Lint & merge fixes * Includes * Documentation step 1 * FBT: output free size considering BT STACK * Documentation step 2 * py lint * Fix music player plugin * unit test stage 1: string allocator, mem, getters, setters, appends, compare, search. * unit test: string equality * unit test: string replace * unit test: string start_with, end_with * unit test: string trim * unit test: utf-8 * Rename * Revert fw_size changes * Simplify CLI backspace handling * Simplify CLI character insert * Merge fixes * Furi: correct filenaming and spelling * Bt: remove furi string include Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -5,10 +5,10 @@
|
||||
#include "check.h"
|
||||
#include "common_defines.h"
|
||||
#include "mutex.h"
|
||||
#include "string.h"
|
||||
|
||||
#include <task.h>
|
||||
#include "log.h"
|
||||
#include <m-string.h>
|
||||
#include <furi_hal_rtc.h>
|
||||
#include <furi_hal_console.h>
|
||||
|
||||
@@ -18,7 +18,7 @@ typedef struct FuriThreadStdout FuriThreadStdout;
|
||||
|
||||
struct FuriThreadStdout {
|
||||
FuriThreadStdoutWriteCallback write_callback;
|
||||
string_t buffer;
|
||||
FuriString* buffer;
|
||||
};
|
||||
|
||||
struct FuriThread {
|
||||
@@ -109,7 +109,7 @@ static void furi_thread_body(void* context) {
|
||||
|
||||
FuriThread* furi_thread_alloc() {
|
||||
FuriThread* thread = malloc(sizeof(FuriThread));
|
||||
string_init(thread->output.buffer);
|
||||
thread->output.buffer = furi_string_alloc();
|
||||
thread->is_service = false;
|
||||
return thread;
|
||||
}
|
||||
@@ -119,7 +119,7 @@ void furi_thread_free(FuriThread* thread) {
|
||||
furi_assert(thread->state == FuriThreadStateStopped);
|
||||
|
||||
if(thread->name) free((void*)thread->name);
|
||||
string_clear(thread->output.buffer);
|
||||
furi_string_free(thread->output.buffer);
|
||||
|
||||
free(thread);
|
||||
}
|
||||
@@ -485,11 +485,11 @@ static size_t __furi_thread_stdout_write(FuriThread* thread, const char* data, s
|
||||
}
|
||||
|
||||
static int32_t __furi_thread_stdout_flush(FuriThread* thread) {
|
||||
string_ptr buffer = thread->output.buffer;
|
||||
size_t size = string_size(buffer);
|
||||
FuriString* buffer = thread->output.buffer;
|
||||
size_t size = furi_string_size(buffer);
|
||||
if(size > 0) {
|
||||
__furi_thread_stdout_write(thread, string_get_cstr(buffer), size);
|
||||
string_reset(buffer);
|
||||
__furi_thread_stdout_write(thread, furi_string_get_cstr(buffer), size);
|
||||
furi_string_reset(buffer);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -516,7 +516,7 @@ size_t furi_thread_stdout_write(const char* data, size_t size) {
|
||||
} else {
|
||||
// string_cat doesn't work here because we need to write the exact size data
|
||||
for(size_t i = 0; i < size; i++) {
|
||||
string_push_back(thread->output.buffer, data[i]);
|
||||
furi_string_push_back(thread->output.buffer, data[i]);
|
||||
if(data[i] == '\n') {
|
||||
__furi_thread_stdout_flush(thread);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user