Allow in-place allocation of FuriString
#2461
Labels
Core+Services
HAL, furi & core system services
Feature Request
New feature or user-story you wanna add to flipper
Describe the enhancement you're suggesting.
Currently the only way to create a
FuriString
is via a function likefuri_string_alloc
that returns an opaqueFuriString*
. However the underlying m-string does support in-place allocation ofstring_t
:In-place allocation of
string_t
allows taking advantage of the short-string optimisation that allocates small strings directly instring_t
, rather than always allocating space on the heap.I believe it would be possible to add a
furi_string_init
andfuri_string_clear
function to the SDK that can initialize a stack-allocatedFuriString
. However this means that a stack-allocatedFuriString
can't be passed into any function that assumes it can take ownership of aFuriString*
(and thus callfuri_string_free
). It would also require exposing the implementation ofFuriString
so that the compiler can allocate the correct amount of space.Anything else?
The reason I'm interested in doing this is that it allows creation of a stack-allocated Rust
FuriString
type in flipperzero-rs (see discussion here). The type would look approximately like the following (note: may have some syntax errors):The text was updated successfully, but these errors were encountered: