Skip to content

Commit

Permalink
add free
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-du-car committed Apr 12, 2024
1 parent fb02efe commit 5ae22a4
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ namespace TelematicBridge
// increase size of buffer.
size_t new_size = 2 * (xb->allocated_size ? xb->allocated_size : 64);
auto new_buf = static_cast<char *>(MALLOC(new_size));
// auto new_buf = new char[new_size];
if (!new_buf)
return -1;
// move old to new.
Expand Down Expand Up @@ -241,7 +240,10 @@ namespace TelematicBridge
}
else
{
json["payload"] = StringToJson(cJSON_Print(msg->payload));
// Render a cJSON entity to text for transfer/storage. Free the char* when finished.
char * payloadPtr = cJSON_Print(msg->payload);
json["payload"] = StringToJson(payloadPtr);
free(payloadPtr);
}
}

Expand Down

0 comments on commit 5ae22a4

Please sign in to comment.