[Answered] Releasing partition iterators ...
Posted: Fri Dec 02, 2016 3:50 am
When we call esp_partition_find() to get an iterator over the partition table, we are told to call esp_partition_iterator_release() to release it when done. That make sense. However, we also find that esp_partition_find() can return NULL. In this case, should we assume that there is nothing to be released and no need to call esp_partition_iterator_release()?
Next we look at esp_parition_next() which takes us to the next iterator. This function takes as input an iterator and returns an iterator. It also says that it can return NULL if there is no next entry. In this case ... I am confused on what to release in a variety of cases.
If I code:
Then the final value of current_iterator will be NULL ... I'm assuming that again there is nothing to release? It is starting to feel to like the only time we call esp_partition_iterator_release() is when:
a) We got an initial non NULL value
b) We have either not called esp_partition_next() or the last call to esp_parition_next() was not NULL
Next we look at esp_parition_next() which takes us to the next iterator. This function takes as input an iterator and returns an iterator. It also says that it can return NULL if there is no next entry. In this case ... I am confused on what to release in a variety of cases.
If I code:
Code: Select all
current_iterator = esp_partition_next(current_iterator);
a) We got an initial non NULL value
b) We have either not called esp_partition_next() or the last call to esp_parition_next() was not NULL