mirror of https://github.com/PentHertz/srsLTE.git
dynamically allocate log_str buffer for hex dumps
the developer needs to make sure that [info,debug,warning,error]_hex() is used wisely in the code as all log_str are now heap-allocated
This commit is contained in:
parent
cf1e742120
commit
486b42e5a7
|
@ -31,6 +31,9 @@
|
|||
|
||||
namespace srslte{
|
||||
|
||||
#define CHARS_FOR_HEX_DUMP(size) \
|
||||
(3 * size + size / 16 * 20) // 3 chars per byte, plus 20 per line for position and newline)
|
||||
|
||||
log_filter::log_filter() : log()
|
||||
{
|
||||
do_tti = false;
|
||||
|
@ -75,9 +78,9 @@ void log_filter::all_log(
|
|||
if (logger_h) {
|
||||
logger::unique_log_str_t log_str = nullptr;
|
||||
|
||||
if (long_msg) {
|
||||
if (long_msg || hex) {
|
||||
// For long messages, dynamically allocate a new log_str with enough size outside the pool.
|
||||
uint32_t log_str_msg_len = sizeof(buffer_tti) + sizeof(buffer_time) + 20 + size;
|
||||
uint32_t log_str_msg_len = sizeof(buffer_tti) + sizeof(buffer_time) + 20 + strlen(msg) + CHARS_FOR_HEX_DUMP(size);
|
||||
log_str = logger::unique_log_str_t(new logger::log_str(nullptr, log_str_msg_len), logger::log_str_deleter());
|
||||
} else {
|
||||
log_str = logger_h->allocate_unique_log_str();
|
||||
|
|
Loading…
Reference in New Issue