[Answered]: Release of memory passed by reference to ESP-IDF functions
Posted: Tue Jul 18, 2017 12:42 am
There are some functions that take a pointer to memory as inputs. What, if anything, can we say about the ability to release this memory after an API call?
For example, imagine the following pseudo code:
uint8_t *pMem = malloc(size);
some_esp_idf_function(pMem);
free(pMem);
Do we have confidence that when an ESP-IDF function returns, it won't still have kept a reference to some of the memory?
Here is a concrete example that caused me to think along these lines. There is a function called:
esp_ble_gatts_add_char() - see http://esp-idf.readthedocs.io/en/latest ... _control_t
one of its parameters is "char_val" which is a pointer to storage. When esp_ble_gatts_add_char() returns, may I release the storage I allocated to pass into the call?
For example, imagine the following pseudo code:
uint8_t *pMem = malloc(size);
some_esp_idf_function(pMem);
free(pMem);
Do we have confidence that when an ESP-IDF function returns, it won't still have kept a reference to some of the memory?
Here is a concrete example that caused me to think along these lines. There is a function called:
esp_ble_gatts_add_char() - see http://esp-idf.readthedocs.io/en/latest ... _control_t
one of its parameters is "char_val" which is a pointer to storage. When esp_ble_gatts_add_char() returns, may I release the storage I allocated to pass into the call?