Displaying 3 results from an estimated 3 matches for "305158e".
2019 Aug 13
0
[PATCH libnbd 4/4] lib: Add CALL_CALLBACK macro.
...llback (h->debug_callback.user_data, context, msg);
+ CALL_CALLBACK (h->debug_callback, context, msg);
else
fprintf (stderr, "libnbd: debug: %s: %s: %s\n",
h->hname, context ? : "unknown", msg);
diff --git a/lib/internal.h b/lib/internal.h
index 305158e..dc3676a 100644
--- a/lib/internal.h
+++ b/lib/internal.h
@@ -273,6 +273,10 @@ struct command {
uint32_t error; /* Local errno value */
};
+/* Call a callback. */
+#define CALL_CALLBACK(cb, ...) \
+ (cb).callback ((cb).user_data, ##__VA_ARGS__)
+
/* Free a callback.
*
* Note this works...
2019 Aug 13
0
[PATCH libnbd 3/4] lib: Add FREE_CALLBACK macro.
...ck)
- if (h->debug_callback.free)
- /* ignore return value */
- h->debug_callback.free (h->debug_callback.user_data);
- h->debug_callback.callback = NULL;
+ FREE_CALLBACK (h->debug_callback);
return 0;
}
diff --git a/lib/internal.h b/lib/internal.h
index 5996a4f..305158e 100644
--- a/lib/internal.h
+++ b/lib/internal.h
@@ -273,6 +273,20 @@ struct command {
uint32_t error; /* Local errno value */
};
+/* Free a callback.
+ *
+ * Note this works for any type of callback because the basic layout
+ * of the struct is the same for all of them. Therefore casting cb...
2019 Aug 13
8
[PATCH libnbd 0/4] Add free function to callbacks.
Patches 1 & 2 are rather complex, but the end result is that we pass
closures + user_data + free function in single struct parameters as I
described previously in this email:
https://www.redhat.com/archives/libguestfs/2019-August/msg00210.html
Patch 3 adds a convenient FREE_CALLBACK macro which seems a worthwhile
simplification if you buy into 1 & 2.
Patch 4 adds another macro which is