mirror of
https://github.com/neovim/neovim.git
synced 2025-10-02 16:08:36 +00:00
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:
@@ -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
|
||||
|
Reference in New Issue
Block a user