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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user