cJSON
cJSON copied to clipboard
Function print() de-allocate memory before return
I am new to cJSON and I have a question about the function print(). This function returns an (unsigned char *) pointer that points to the print buffer that was allocated from the heap. The buffer is de-allocated before the function returns to a caller. Is this safe? I mean the caller could call another function that uses heap, and that could trash the print buffer since buffer is already released back to the heap.
Never mind, my mistake, I didn't read the code correctly.