Merge remote-tracking branch 'origin/fix-huge-malloc' into integration_2025_w04 (!3211)

Avoid huge calloc by alloc'ing TBs independently

Fix real-time problems on smaller machines due to big calloc(). See the
commit(s) for more details.
This commit is contained in:
Robert Schmidt
2025-01-27 11:40:53 +01:00
9 changed files with 55 additions and 13 deletions
+14
View File
@@ -72,3 +72,17 @@ byte_array_t cp_str_to_ba(const char* str)
return dst;
}
char* cp_ba_to_str(const byte_array_t ba)
{
assert(ba.len > 0);
const size_t sz = ba.len;
char* str = calloc(sz+1, sizeof(char));
assert(str != NULL && "Memory exhausted");
memcpy(str, ba.buf, sz);
str[sz] = '\0';
return str;
}
+1
View File
@@ -42,5 +42,6 @@ void free_byte_array(byte_array_t ba);
bool eq_byte_array(const byte_array_t* m0, const byte_array_t* m1);
byte_array_t cp_str_to_ba(const char* str);
char* cp_ba_to_str(const byte_array_t ba);
#endif