* gas/mips/mips.exp (run_dump_test_arch): Check for the presence
[deliverable/binutils-gdb.git] / gdb / vec.h
index d28fa703ade977df9912a621daf9e80989dac826..e9d5a1583e96b6a82ba586b797d636592a413588 100644 (file)
--- a/gdb/vec.h
+++ b/gdb/vec.h
@@ -1,5 +1,6 @@
 /* Vector API for GDB.
-   Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
+   Free Software Foundation, Inc.
    Contributed by Nathan Sidwell <nathan@codesourcery.com>
 
    This file is part of GDB.
 
 #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).
 
@@ -460,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)                         \
 {                                                                        \
@@ -698,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;                                    \
@@ -956,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)                         \
 {                                                                        \
This page took 0.023913 seconds and 4 git commands to generate.