Skip to content

Tutorial 30: Memory leak after parsing JSON file #13

@asweeney99

Description

@asweeney99

Hi Luca,

You have a memory leak here:
cJSON *json = cJSON_Parse(rcv_buffer);

You need to call the following line to free it:
cJSON_Delete(json);

Reference document for the cJSON library is here:
https://github.com/DaveGamble/cJSON


Given some JSON in a zero terminated string, you can parse it with cJSON_Parse.

cJSON *json = cJSON_Parse(string);

It will parse the JSON and allocate a tree of cJSON items that represents it. Once it returns, you are fully responsible for deallocating it after use with cJSON_Delete.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions