espressif / esp-azure

SDK to connect ESP8266 and ESP32 to Microsoft Azure IoT services
177 stars 92 forks source link

Should I free payload within deviceMethodCallback() (CA-90) #103

Open liudr opened 4 years ago

liudr commented 4 years ago

Here is the function: static int deviceMethodCallback(const char method_name, const unsigned char payload, size_t size, unsigned char* response, size_t response_size, void* userContextCallback)

I wonder if I should free(payload). No explanation was provided by ESP_AZURE. I wonder how to handle the resources presented to deviceMethodCallback(). Thanks.

shahpiyushv commented 4 years ago

@liudr , I am not sure if this code you have mentioned is in the esp porting layer or in azure-iot-sdk-c. But in any case, as per my understanding, since it is a "const", it isn't expected to be freed