2
0
Эх сурвалжийг харах

utarray.h: preserve constness in utarray_str_cpy

Make local variable const * to preserve the constness of the passed
argument src. This fixes compiler warnings from -Wcast-qual.
Olaf Bergmann 5 жил өмнө
parent
commit
ba2fbfdcd8
1 өөрчлөгдсөн 3 нэмэгдсэн , 2 устгасан
  1. 3 2
      src/utarray.h

+ 3 - 2
src/utarray.h

@@ -232,8 +232,9 @@ typedef struct {
 
 /* last we pre-define a few icd for common utarrays of ints and strings */
 static void utarray_str_cpy(void *dst, const void *src) {
-  char **_src = (char**)src, **_dst = (char**)dst;
-  *_dst = (*_src == NULL) ? NULL : strdup(*_src);
+  char *const *srcc = (char *const *)src;
+  char **dstc = (char**)dst;
+  *dstc = (*srcc == NULL) ? NULL : strdup(*srcc);
 }
 static void utarray_str_dtor(void *elt) {
   char **eltc = (char**)elt;