summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryangwei <[email protected]>2024-08-08 15:35:00 +0800
committerluwenpeng <[email protected]>2024-08-12 15:48:37 +0800
commit2d408b3503750ef16a202c7ba7f1e84e40723027 (patch)
tree9f357df867afc4560dbbc8af0cbbe7806ebeba97
parent90ca08568edfd70ff77cf4c045fda27b36a14d1c (diff)
✨ feat(exdata & mq header): define default free_cb
-rw-r--r--include/stellar/stellar_exdata.h8
-rw-r--r--include/stellar/stellar_mq.h7
2 files changed, 15 insertions, 0 deletions
diff --git a/include/stellar/stellar_exdata.h b/include/stellar/stellar_exdata.h
index 605cb12..199ac56 100644
--- a/include/stellar/stellar_exdata.h
+++ b/include/stellar/stellar_exdata.h
@@ -1,5 +1,6 @@
#pragma once
+#include "utils.h"
#include "stellar.h"
#ifdef __cplusplus
@@ -8,6 +9,13 @@ extern "C"
#endif
typedef void stellar_exdata_free(int idx, void *ex_ptr, void *arg);
+
+
+inline static void stellar_exdata_free_default(int idx __unused, void *ex_ptr, void *arg __unused)
+{
+ if(ex_ptr)FREE(ex_ptr);
+}
+
int stellar_exdata_new_index(struct stellar *st, const char *name, stellar_exdata_free *free_func,void *arg);
//packet exdata api
diff --git a/include/stellar/stellar_mq.h b/include/stellar/stellar_mq.h
index 9267868..7b826d5 100644
--- a/include/stellar/stellar_mq.h
+++ b/include/stellar/stellar_mq.h
@@ -1,4 +1,6 @@
#pragma once
+
+#include "utils.h"
#include "stellar.h"
#ifdef __cplusplus
@@ -9,6 +11,11 @@ extern "C"
//topic api
typedef void stellar_msg_free_cb_func(void *msg, void *msg_free_arg);
+inline static void stellar_msg_free_default(void *msg, void *msg_free_arg __unused)
+{
+ if(msg)FREE(msg);
+}
+
//return topic_id
int stellar_mq_create_topic(struct stellar *st, const char *topic_name, stellar_msg_free_cb_func *msg_free_cb, void *msg_free_arg);
int stellar_mq_get_topic_id(struct stellar *st, const char *topic_name);