aboutsummaryrefslogtreecommitdiff
path: root/gdb/common/common-utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/common/common-utils.h')
-rw-r--r--gdb/common/common-utils.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/gdb/common/common-utils.h b/gdb/common/common-utils.h
index 4926a32..feb4790 100644
--- a/gdb/common/common-utils.h
+++ b/gdb/common/common-utils.h
@@ -23,6 +23,8 @@
#include <string>
#include <vector>
+#include "poison.h"
+
/* If possible, define FUNCTION_NAME, a macro containing the name of
the function being defined. Since this macro may not always be
defined, all uses must be protected by appropriate macro definition
@@ -47,7 +49,17 @@
/* Like xmalloc, but zero the memory. */
void *xzalloc (size_t);
-void xfree (void *);
+template <typename T>
+static void
+xfree (T *ptr)
+{
+ static_assert (IsFreeable<T>::value, "Trying to use xfree with a non-POD \
+data type. Use operator delete instead.");
+
+ if (ptr != NULL)
+ free (ptr); /* ARI: free */
+}
+
/* Like asprintf and vasprintf, but return the string, throw an error
if no memory. */