mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2025-10-11 07:32:34 +02:00
* js: value destructuring and tests * js: temporary fix to see size impact * js_val: reduce code size 1 * i may be stupid. * test: js_value args * Revert "js: temporary fix to see size impact" This reverts commit f51d726dbafc4300d3552020de1c3b8f9ecd3ac1. * pvs: silence warnings * style: formatting * pvs: silence warnings? * pvs: silence warnings?? * js_value: redesign declaration types for less code * js: temporary fix to see size impact * style: formatting * pvs: fix helpful warnings * js_value: reduce .rodata size * pvs: fix helpful warning * js_value: reduce code size 1 * fix build error * style: format * Revert "js: temporary fix to see size impact" This reverts commit d6a46f01794132e882e03fd273dec24386a4f8ba. * style: format * js: move to new arg parser * style: format * feat: all js views done * js, toolbox: generalize string owning * toolbox: silence pvs warning --------- Co-authored-by: hedger <hedger@nanode.su> Co-authored-by: hedger <hedger@users.noreply.github.com>
19 lines
601 B
C
19 lines
601 B
C
#include "str_buffer.h"
|
|
|
|
const char* str_buffer_make_owned_clone(StrBuffer* buffer, const char* str) {
|
|
char* owned = strdup(str);
|
|
buffer->n_owned_strings++;
|
|
buffer->owned_strings =
|
|
realloc(buffer->owned_strings, buffer->n_owned_strings * sizeof(const char*)); // -V701
|
|
buffer->owned_strings[buffer->n_owned_strings - 1] = owned;
|
|
return owned;
|
|
}
|
|
|
|
void str_buffer_clear_all_clones(StrBuffer* buffer) {
|
|
for(size_t i = 0; i < buffer->n_owned_strings; i++) {
|
|
free(buffer->owned_strings[i]);
|
|
}
|
|
free(buffer->owned_strings);
|
|
buffer->owned_strings = NULL;
|
|
}
|