Fix the lack of memrchr on W32
[oweals/gnunet.git] / src / gns / gnunet-service-gns_resolver.c
index 6d77997e71999311e2c7adff54d81cfd83482a18..c36fa8d17a6616b31313f9d9bfaa59453a3ad35c 100644 (file)
@@ -1324,6 +1324,18 @@ fail_resolution (void *cls,
   GNS_resolver_lookup_cancel (rh);
 }
 
+#ifdef WINDOWS
+/* Don't have this on W32, here's a naive implementation */
+void *memrchr (const void *s, int c, size_t n)
+{
+  size_t i;
+  unsigned char *ucs = (unsigned char *) s;
+  for (i = n - 1; i >= 0; i--)
+    if (ucs[i] == c)
+      return (void *) &ucs[i];
+  return NULL;
+}
+#endif
 
 /**
  * Get the next, rightmost label from the name that we are trying to resolve,