From: Daniel Wagner <[email protected]>
There is a common pattern when writing a callback function. Let's
add a few helper for this.
This is shamelessly stolen from oFono.
---
include/types.h | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/include/types.h b/include/types.h
index 0f671ec..051151a 100644
--- a/include/types.h
+++ b/include/types.h
@@ -22,6 +22,8 @@
#ifndef __CONNMAN_TYPES_H
#define __CONNMAN_TYPES_H
+#include <glib.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -38,6 +40,23 @@ typedef int connman_bool_t;
typedef unsigned char connman_uint8_t;
typedef unsigned short connman_uint16_t;
+struct cb_data {
+ void *cb;
+ void *user_data;
+ void *data;
+};
+
+static inline struct cb_data *cb_data_new(void *cb, void *user_data)
+{
+ struct cb_data *ret;
+
+ ret = g_new0(struct cb_data, 1);
+ ret->cb = cb;
+ ret->user_data = user_data;
+
+ return ret;
+}
+
#ifdef __cplusplus
}
#endif
--
1.8.2.rc3.16.gce432ca
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman