diff options
Diffstat (limited to 'gdb/vec.h')
-rw-r--r-- | gdb/vec.h | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -184,6 +184,13 @@ #define VEC_free(T,V) (VEC_OP(T,free)(&V)) +/* A cleanup function for a vector. + void VEC_T_cleanup(void *); + + Clean up a vector. */ + +#define VEC_cleanup(T) (VEC_OP(T,cleanup)) + /* Use these to determine the required size and initialization of a vector embedded within another structure (as the final member). @@ -461,6 +468,15 @@ static inline void VEC_OP (T,free) \ *vec_ = NULL; \ } \ \ +static inline void VEC_OP (T,cleanup) \ + (void *arg_) \ +{ \ + VEC(T) **vec_ = arg_; \ + if (*vec_) \ + vec_free_ (*vec_); \ + *vec_ = NULL; \ +} \ + \ static inline int VEC_OP (T,reserve) \ (VEC(T) **vec_, int alloc_ VEC_ASSERT_DECL) \ { \ @@ -699,6 +715,15 @@ static inline void VEC_OP (T,free) \ *vec_ = NULL; \ } \ \ +static inline void VEC_OP (T,cleanup) \ + (void *arg_) \ +{ \ + VEC(T) **vec_ = arg_; \ + if (*vec_) \ + vec_free_ (*vec_); \ + *vec_ = NULL; \ +} \ + \ static inline VEC(T) *VEC_OP (T,copy) (VEC(T) *vec_) \ { \ size_t len_ = vec_ ? vec_->num : 0; \ @@ -957,6 +982,15 @@ static inline void VEC_OP (T,free) \ *vec_ = NULL; \ } \ \ +static inline void VEC_OP (T,cleanup) \ + (void *arg_) \ +{ \ + VEC(T) **vec_ = arg_; \ + if (*vec_) \ + vec_free_ (*vec_); \ + *vec_ = NULL; \ +} \ + \ static inline int VEC_OP (T,reserve) \ (VEC(T) **vec_, int alloc_ VEC_ASSERT_DECL) \ { \ |