From 91ccbb399f0a799a16dee670b29f171a18b413d1 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 10 Sep 2020 16:45:14 -0700 Subject: [PATCH] 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 Part-of: --- src/util/xmlconfig.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/util/xmlconfig.c b/src/util/xmlconfig.c index a02e47e0ae5..84d20ae9afc 100644 --- a/src/util/xmlconfig.c +++ b/src/util/xmlconfig.c @@ -92,14 +92,12 @@ findOption(const driOptionCache *cache, const char *name) 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) {