]> granicus.if.org Git - graphviz/commitdiff
take a const pointer in refsymbind
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 4 Jul 2021 03:37:10 +0000 (20:37 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 18 Jul 2021 00:27:58 +0000 (17:27 -0700)
This is preparation for accepting const pointers in the agstrdup functions.
Related to #634.

lib/cgraph/refstr.c

index f3dbfacb0398e4ce3f38bfd0ab9fff939e170946..c80eebb9e5d5ceaf1d44fe8db0edfc446ce7d42c 100644 (file)
@@ -62,10 +62,19 @@ int agstrclose(Agraph_t * g)
     return agdtclose(g, refdict(g));
 }
 
-static refstr_t *refsymbind(Dict_t * strdict, char *s)
+static refstr_t *refsymbind(Dict_t * strdict, const char *s)
 {
     refstr_t key, *r;
-    key.s = s;
+// Suppress Clang/GCC -Wcast-qual warning. Casting away const here is acceptable
+// as dtsearch does not modify its input key.
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-qual"
+#endif
+    key.s = (char*)s;
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
     r = dtsearch(strdict, &key);
     return r;
 }