/* Shared general utility routines for GDB, the GNU debugger.
- Copyright (C) 1986-2017 Free Software Foundation, Inc.
+ Copyright (C) 1986-2018 Free Software Foundation, Inc.
This file is part of GDB.
#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
/* 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. */
joining all the arguments with a whitespace separating them. */
extern std::string stringify_argv (const std::vector<char *> &argv);
+/* Return true if VALUE is in [LOW, HIGH]. */
+
+template <typename T>
+static bool
+in_inclusive_range (T value, T low, T high)
+{
+ return value >= low && value <= high;
+}
+
#endif