mirror of
https://github.com/neovim/neovim.git
synced 2025-10-06 01:46:29 +00:00
refactor: introduce XFREE_CLEAR()
Unfortunately we cannot indiscriminately replace xfree() with XFREE_CLEAR(), because comparing pointers after freeing them is a common pattern. Example in `tv_list_remove_items()`: xfree(li); if (li == item2) { break; } Instead we can do it selectively/explicitly. ref #1375
This commit is contained in:
@@ -136,14 +136,14 @@ static inline void funcprefix##_rb_free(TypeName##RingBuffer *const rb) \
|
||||
RINGBUF_FORALL(rb, RBType, rbitem) { \
|
||||
rbfree(rbitem); \
|
||||
} \
|
||||
xfree(rb->buf); \
|
||||
XFREE_CLEAR(rb->buf); \
|
||||
} \
|
||||
\
|
||||
static inline void funcprefix##_rb_dealloc(TypeName##RingBuffer *const rb) \
|
||||
REAL_FATTR_UNUSED; \
|
||||
static inline void funcprefix##_rb_dealloc(TypeName##RingBuffer *const rb) \
|
||||
{ \
|
||||
xfree(rb->buf); \
|
||||
XFREE_CLEAR(rb->buf); \
|
||||
} \
|
||||
\
|
||||
static inline void funcprefix##_rb_push(TypeName##RingBuffer *const rb, \
|
||||
|
Reference in New Issue
Block a user