util/xmlconfig: Drop silly open-coded strdup.
The comment about using "malloc"? The strdup man page says 'Memory for
the new string is obtained with malloc(3), and can be freed with free(3)'
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6916>
diff --git a/src/util/xmlconfig.c b/src/util/xmlconfig.c
index a02e47e..84d20ae 100644
--- a/src/util/xmlconfig.c
+++ b/src/util/xmlconfig.c
@@ -92,14 +92,12 @@
return hash;
}
-/** \brief Like strdup but using malloc and with error checking. */
+/** \brief Like strdup with error checking. */
#define XSTRDUP(dest,source) do { \
- uint32_t len = strlen (source); \
- if (!(dest = malloc(len+1))) { \
+ if (!(dest = strdup(source))) { \
fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__); \
abort(); \
} \
- memcpy (dest, source, len+1); \
} while (0)
static int compare (const void *a, const void *b) {