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

@@ -37,10 +37,7 @@ void ga_clear(garray_T *gap)
/// @param gap
void ga_clear_strings(garray_T *gap)
{
for (int i = 0; i < gap->ga_len; ++i) {
free(((char_u **)(gap->ga_data))[i]);
}
ga_clear(gap);
GA_DEEP_CLEAR_PTR(gap);
}
/// Initialize a growing array.