summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorzhengchao <[email protected]>2022-07-22 12:03:08 +0800
committerzhengchao <[email protected]>2022-07-22 12:03:08 +0800
commit1ee76d1095e71d16ef244ce760baf7e4021ba2d2 (patch)
tree109da6e5f416da7363097ae114a56d298ec1a454 /include
parentc42940b68393abd69e0851dd522bfabbb6e12621 (diff)
fix memory leaks caused by remote command processing
Diffstat (limited to 'include')
-rw-r--r--include/swarmkv/swarmkv.h19
1 files changed, 10 insertions, 9 deletions
diff --git a/include/swarmkv/swarmkv.h b/include/swarmkv/swarmkv.h
index 67476d8..9da35cc 100644
--- a/include/swarmkv/swarmkv.h
+++ b/include/swarmkv/swarmkv.h
@@ -30,16 +30,14 @@ struct swarmkv_reply
{
enum swarmkv_reply_type type;
long long integer; /* The integer when type is SWARMKV_REPLY_INTEGER */
- int len; /* Length of string */
- char *str; /* Used for SWARMKV_REPLY_ERROR, SWARMKV_REPLY_STATUS, SWARMKV_NODE and SWARMKV_REPLY_STRING */
- size_t n_element; /* number of elements, for SWARMKV_REPLY_ARRAY */
+ int len; /* Length of string */
+ char *str; /* Used for SWARMKV_REPLY_ERROR, SWARMKV_REPLY_STATUS, SWARMKV_NODE and SWARMKV_REPLY_STRING */
+ size_t n_element; /* number of elements, for SWARMKV_REPLY_ARRAY */
struct swarmkv_reply **elements;/* elements vector for SWARMKV_REPLY_ARRAY */
};
void swarmkv_reply_free(struct swarmkv_reply *reply);
-typedef void swarmkv_cmd_callback_func_t(const struct swarmkv_reply* reply, void * arg);
-struct swarmkv;
struct swarmkv_options;
struct swarmkv_options* swarmkv_options_new(void);
int swarmkv_options_set_p2p_port(struct swarmkv_options *opts, unsigned int p2p_port);
@@ -50,13 +48,18 @@ int swarmkv_options_set_consul_port(struct swarmkv_options *opts, unsigned int c
int swarmkv_options_set_dryrun(struct swarmkv_options *opts);
int swarmkv_options_set_worker_thread_number(struct swarmkv_options *opts, size_t nr_worker_threads);
-struct swarmkv *swarmkv_open(struct swarmkv_options *opts, const char * db_name, char **err);
-void swarmkv_close(struct swarmkv * db);
+struct swarmkv;
+struct swarmkv *swarmkv_open(struct swarmkv_options *opts, const char * db_name, char **err);
+void swarmkv_close(struct swarmkv * db);
+//Blocking function
struct swarmkv_reply* swarmkv_command(struct swarmkv *db, const char *format, ...);
+//Non-blockign function
+typedef void swarmkv_cmd_callback_func_t(const struct swarmkv_reply* reply, void * arg);
+
void swarmkv_get(struct swarmkv * db,
const char * key, size_t keylen, swarmkv_cmd_callback_func_t * cb, void * arg);
void swarmkv_set(struct swarmkv * db,
@@ -86,7 +89,5 @@ const char *swarmkv_get_command_hint(struct swarmkv *db, const char* cmd_name);
#ifdef __cplusplus
} /* end extern "C" */
-
-
#endif