Skip to content

Commit cec5a85

Browse files
author
Cruz Monrreal
authored
Merge pull request #10354 from hasnainvirk/compile_error_at_handler
Cellular: Using new rather than malloc in debug_print
2 parents 67de89d + 9229aba commit cec5a85

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

features/cellular/framework/AT/ATHandler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,7 @@ void ATHandler::debug_print(const char *p, int len, ATType type)
13201320
#if MBED_CONF_CELLULAR_DEBUG_AT
13211321
if (_debug_on) {
13221322
const int buf_size = len * 4 + 1; // x4 -> reserve space for extra characters, +1 -> terminating null
1323-
char *buffer = (char *)malloc(buf_size);
1323+
char *buffer = new char [buf_size];
13241324
if (buffer) {
13251325
memset(buffer, 0, buf_size);
13261326

@@ -1350,7 +1350,7 @@ void ATHandler::debug_print(const char *p, int len, ATType type)
13501350
tr_info("AT ERR (%2d): %s", len, buffer);
13511351
}
13521352

1353-
free(buffer);
1353+
delete [] buffer;
13541354
} else {
13551355
tr_error("AT trace unable to allocate buffer!");
13561356
}

0 commit comments

Comments
 (0)