Skip to contentSkip to conversation

genl: Introduce new api

PATCH_v2 Ravi kumar Veeramally 2 participants 2 messages Feb 27, 2015

lore
Share & tools
lore
#0 lore raw

Introducing l_genl_family_send_and_unref, l_genl_family_dump_and_unref wrapper functions for l_genl_family_send and l_genl_family_dump but it unref the message no matter of what the result is.

---
 ell/genl.c | 28 ++++++++++++++++++++++++++++
 ell/genl.h | 10 ++++++++++
 2 files changed, 38 insertions(+)
ell/genl.c +28 -0
index 2ef6a34..e84d801 100644
@@ -1091,6 +1091,20 @@ unsigned int l_genl_family_send(struct l_genl_family *family,
 						user_data, destroy);
 }
 
+unsigned int l_genl_family_send_and_unref(struct l_genl_family *family,
+						struct l_genl_msg *msg,
+						l_genl_msg_func_t callback,
+						void *user_data,
+						l_genl_destroy_func_t destroy)
+{
+	unsigned int id;
+
+	id = l_genl_family_send(family, msg, callback, user_data, destroy);
+	l_genl_msg_unref(msg);
+
+	return id;
+}
+
 unsigned int l_genl_family_dump(struct l_genl_family *family,
 				struct l_genl_msg *msg, l_genl_msg_func_t callback,
 				void *user_data, l_genl_destroy_func_t destroy)
@@ -1099,6 +1113,20 @@ unsigned int l_genl_family_dump(struct l_genl_family *family,
 							user_data, destroy);
 }
 
+unsigned int l_genl_family_dump_and_unref(struct l_genl_family *family,
+						struct l_genl_msg *msg,
+						l_genl_msg_func_t callback,
+						void *user_data,
+						l_genl_destroy_func_t destroy)
+{
+	unsigned int id;
+
+	id = l_genl_family_dump(family, msg, callback, user_data, destroy);
+	l_genl_msg_unref(msg);
+
+	return id;
+}
+
 static bool match_request_id(const void *a, const void *b)
 {
 	const struct genl_request *request = a;
ell/genl.h +10 -0
index c628b8c..1f58a94 100644
@@ -101,9 +101,19 @@ bool l_genl_family_can_dump(struct l_genl_family *family, uint8_t cmd);
 unsigned int l_genl_family_send(struct l_genl_family *family,
 				struct l_genl_msg *msg, l_genl_msg_func_t callback,
 				void *user_data, l_genl_destroy_func_t destroy);
+unsigned int l_genl_family_send_and_unref(struct l_genl_family *family,
+						struct l_genl_msg *msg,
+						l_genl_msg_func_t callback,
+						void *user_data,
+						l_genl_destroy_func_t destroy);
 unsigned int l_genl_family_dump(struct l_genl_family *family,
 				struct l_genl_msg *msg, l_genl_msg_func_t callback,
 				void *user_data, l_genl_destroy_func_t destroy);
+unsigned int l_genl_family_dump_and_unref(struct l_genl_family *family,
+						struct l_genl_msg *msg,
+						l_genl_msg_func_t callback,
+						void *user_data,
+						l_genl_destroy_func_t destroy);
 bool l_genl_family_cancel(struct l_genl_family *family, unsigned int id);
 
 bool l_genl_family_has_group(struct l_genl_family *family, const char *group);
Signature · 1 line
2.1.0
#1 lore raw

Hi Ravi,

Quoted 8 lines · Ravi kumar Veeramally

Introducing l_genl_family_send_and_unref, l_genl_family_dump_and_unref wrapper functions for l_genl_family_send and l_genl_family_dump but it unref the message no matter of what the result is.

---
  ell/genl.c | 28 ++++++++++++++++++++++++++++
  ell/genl.h | 10 ++++++++++
  2 files changed, 38 insertions(+)

I decided to fix this differently. The fix was to have l_genl_family_send and l_genl_family_dump not take a ref, since we never actually kept the message after sending it.

This also makes it consistent with the ell dbus message API.

Regards,
-Denis