Updated Serbian and Russian translations for various sub-directories
[binutils-gdb.git] / gdbsupport / common-utils.h
index 4429f086fce34d201a85ab087742b862ac57748a..224e1f3122268b49e598f76158a5c5e84cc6ed5b 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <string>
 #include <vector>
+#include "gdbsupport/byte-vector.h"
 
 #include "poison.h"
 
@@ -59,7 +60,11 @@ xfree (T *ptr)
 data type.  Use operator delete instead.");
 
   if (ptr != NULL)
-    free (ptr);                /* ARI: free */
+#ifdef GNULIB_NAMESPACE
+    GNULIB_NAMESPACE::free (ptr);      /* ARI: free */
+#else
+    free (ptr);                                /* ARI: free */
+#endif
 }
 
 
@@ -112,16 +117,8 @@ std::string extract_string_maybe_quoted (const char **arg);
 
 extern const char *safe_strerror (int);
 
-/* Return true if the start of STRING matches PATTERN, false otherwise.  */
-
-static inline bool
-startswith (const char *string, const char *pattern)
-{
-  return strncmp (string, pattern, strlen (pattern)) == 0;
-}
-
-/* Version of startswith that takes string_view arguments.  See comment
-   above.  */
+/* Version of startswith that takes string_view arguments.  Return
+   true if the start of STRING matches PATTERN, false otherwise.  */
 
 static inline bool
 startswith (gdb::string_view string, gdb::string_view pattern)
@@ -195,4 +192,18 @@ in_inclusive_range (T value, T low, T high)
 extern ULONGEST align_up (ULONGEST v, int n);
 extern ULONGEST align_down (ULONGEST v, int n);
 
+/* Convert hex digit A to a number, or throw an exception.  */
+extern int fromhex (int a);
+
+/* HEX is a string of characters representing hexadecimal digits.
+   Convert pairs of hex digits to bytes and store sequentially into
+   BIN.  COUNT is the maximum number of characters to convert.  This
+   will convert fewer characters if the number of hex characters
+   actually seen is odd, or if HEX terminates before COUNT characters.
+   Returns the number of characters actually converted.  */
+extern int hex2bin (const char *hex, gdb_byte *bin, int count);
+
+/* Like the above, but return a gdb::byte_vector.  */
+gdb::byte_vector hex2bin (const char *hex);
+
 #endif /* COMMON_COMMON_UTILS_H */