GA_DEEP_FREE_PTR: deep free macro for garrays that store simple pointers

By "simple pointer" I mean a pointer that can be freed with a call to `free`
without leaking any member pointer.

This macro does exactly what `ga_clear_strings` does.
This commit is contained in:
Felipe Oliveira Carvalho
2014-12-11 12:42:52 -03:00
parent b603404487
commit 8ee5659d83
4 changed files with 11 additions and 14 deletions

View File

@@ -61,4 +61,12 @@ static inline void *ga_append_via_ptr(garray_T *gap, size_t item_size)
ga_clear(_gap); \
} while (false)
#define FREE_PTR_PTR(ptr) free(*(ptr))
/// Call `free` for every pointer stored in the garray and then frees the
/// garray.
///
/// @param gap the garray to be freed
#define GA_DEEP_CLEAR_PTR(gap) GA_DEEP_CLEAR(gap, void*, FREE_PTR_PTR)
#endif // NVIM_GARRAY_H