[Github-comments] [geany/geany] [devel] Improving utils_free_pointers() (#2288)

Nick Treleaven notifications at xxxxx
Fri Sep 6 13:50:11 UTC 2019


`utils_free_pointers()` has a clear name, but requires a leading count of pointers, which could be too big or too small, and a trailing NULL, to try to detect if the count is too big.

I realized now we require C99, we can solve all these issues with a macro:
```c
#define FREE_EACH(...) do { \
    void *_arr[] = {__VA_ARGS__}; \
    for (guint _i = 0; _i < G_N_ELEMENTS(_arr); _i++) \
        g_free(_arr[_i]); \
    } while (0)
```
Shall I make a PR?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/issues/2288
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20190906/e16bd3ea/attachment.html>


More information about the Github-comments mailing list