genl: Introduce new api
PATCH 1/1 genl: Introduce new api
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 | 30 ++++++++++++++++++++++++++++++ ell/genl.h | 10 ++++++++++ 2 files changed, 40 insertions(+)
ell/genl.c +30 -0
@@ -1091,6 +1091,21 @@ 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); + msg =NULL ; + +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 +1114,21 @@ 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); + msg =NULL ; + +return id; +} +static bool match_request_id (const void *a,const void *b) {const struct genl_request *request = a;
ell/genl.h +10 -0
@@ -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
Hi Ravi,
Quoted 17 lines
Introducing
l_genl_family_send_and_unref,l_genl_family_dump_and_unrefwrapper functions forl_genl_family_sendandl_genl_family_dumpbut it unref the message no matter of what the result is.
---ell/genl.c| 30 ++++++++++++++++++++++++++++++ell/genl.h| 10 ++++++++++2 files changed, 40 insertions(+)ell/genl.c +1
-0@@ -1091,6 +1091,21 @@ 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,
ell/genl.c unsigned int l_genl_family_send(struct l_genl_family *family, · line 1104
Quoted 10 lines
ell/genl.c +10
-0+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); + msg =NULL ;
remove the msg = NULL here. That is useless. Once you leave the scope of this function, that pointer is no longer valid anyway.
Remember that these pointers are local to its function. You can not change the pointer in the caller this way.
Quoted 12 lines
ell/genl.c +5
-0+ +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 +1114,21 @@ 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,
ell/genl.c unsigned int l_genl_family_dump(struct l_genl_family *family, · line 1127
Quoted 10 lines
ell/genl.c +10
-0+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); + msg =NULL ;
Same as above.
Quoted 19 lines
ell/genl.c +4
-0+ +return id; +} +static bool match_request_id (const void *a,const void *b) {const struct genl_request *request = a;ell/genl.h +4
-0@@ -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,
ell/genl.h bool l_genl_family_can_dump(struct l_genl_family *family, uint8_t cmd); · line 117
Quoted 10 lines
ell/genl.h +6
-0+ 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);
Regards
Marcel