]> git.ozlabs.org Git - ccan/blobdiff - ccan/ptr_valid/_info
ptr_valid: test whether a ptr is valid.
[ccan] / ccan / ptr_valid / _info
diff --git a/ccan/ptr_valid/_info b/ccan/ptr_valid/_info
new file mode 100644 (file)
index 0000000..b577535
--- /dev/null
@@ -0,0 +1,28 @@
+#include <string.h>
+#include "config.h"
+
+/**
+ * ptr_valid - test whether a pointer is safe to dereference.
+ *
+ * This little helper tells you if an address is mapped; it doesn't tell you
+ * if it's read-only (or execute only).
+ *
+ * License: BSD-MIT
+ *
+ * Ccanlint:
+ *     // Our child actually crashes, but that's OK!
+ *     tests_pass_valgrind test/run.c:--child-silent-after-fork=yes
+ */
+int main(int argc, char *argv[])
+{
+       /* Expect exactly one argument */
+       if (argc != 2)
+               return 1;
+
+       if (strcmp(argv[1], "depends") == 0) {
+               printf("ccan/noerr\n");
+               return 0;
+       }
+
+       return 1;
+}