+/* Convenience wrapper around fwrite, that returns the number of bytes written
+ * to the file instead of the number of objects (see fwrite(3)) and -1 in the
+ * case of an error. It also supports a NULL *fp to skip writing altogether
+ * instead of writing to /dev/null. */
+static int rdbWriteRaw(FILE *fp, void *p, size_t len) {
+ if (fp != NULL && fwrite(p,len,1,fp) == 0) return -1;
+ return len;
+}
+