summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Noordhuis <pcnoordhuis@gmail.com>2010-10-19 14:19:47 +0200
committerPieter Noordhuis <pcnoordhuis@gmail.com>2010-10-19 14:19:51 +0200
commitba42ab2ef8fcf9bf88c0d68414d24c3bb00e00c8 (patch)
tree2a2fcd81fad6b9f74a8eea16e7e549cfa9bfdcfe
parentf9596db90bf030dfbd008151521d1c72e1e497e4 (diff)
Revert privdata in context callbacks to being non-const
-rw-r--r--hiredis.c6
-rw-r--r--hiredis.h10
-rw-r--r--test.c16
3 files changed, 16 insertions, 16 deletions
diff --git a/hiredis.c b/hiredis.c
index 052285b..13da532 100644
--- a/hiredis.c
+++ b/hiredis.c
@@ -631,20 +631,20 @@ redisContext *redisConnectNonBlock(const char *ip, int port, redisReplyFunctions
}
/* Register callback that is triggered when redisDisconnect is called. */
-void redisSetDisconnectCallback(redisContext *c, redisContextCallbackFn *fn, const void *privdata) {
+void redisSetDisconnectCallback(redisContext *c, redisContextCallbackFn *fn, void *privdata) {
c->cbDisconnect.fn = fn;
c->cbDisconnect.privdata = privdata;
}
/* Register callback that is triggered when a command is put in the output
* buffer when the context is non-blocking. */
-void redisSetCommandCallback(redisContext *c, redisContextCallbackFn *fn, const void *privdata) {
+void redisSetCommandCallback(redisContext *c, redisContextCallbackFn *fn, void *privdata) {
c->cbCommand.fn = fn;
c->cbCommand.privdata = privdata;
}
/* Register callback that is triggered when the context is free'd. */
-void redisSetFreeCallback(redisContext *c, redisContextCallbackFn *fn, const void *privdata) {
+void redisSetFreeCallback(redisContext *c, redisContextCallbackFn *fn, void *privdata) {
c->cbFree.fn = fn;
c->cbFree.privdata = privdata;
}
diff --git a/hiredis.h b/hiredis.h
index 75419f5..8a0e2aa 100644
--- a/hiredis.h
+++ b/hiredis.h
@@ -77,7 +77,7 @@ typedef struct redisReplyObjectFunctions {
struct redisContext; /* need forward declaration of redisContext */
/* Callbacks triggered on non-reply events. */
-typedef void (redisContextCallbackFn)(struct redisContext*, const void*);
+typedef void (redisContextCallbackFn)(struct redisContext*, void*);
/* Reply callback prototype and container */
typedef void (redisCallbackFn)(struct redisContext*, redisReply*, const void*);
@@ -85,7 +85,7 @@ typedef void (redisCallbackFn)(struct redisContext*, redisReply*, const void*);
/* Callback containers */
typedef struct redisContextCallback {
redisContextCallbackFn *fn;
- const void *privdata;
+ void *privdata;
} redisContextCallback;
typedef struct redisCallback {
@@ -135,16 +135,16 @@ int redisProcessCallbacks(redisContext *c);
/* The disconnect callback is called *immediately* when redisDisconnect()
* is called. It is called only once for every redisContext (since hiredis
* currently does not support reconnecting an existing context). */
-void redisSetDisconnectCallback(redisContext *c, redisContextCallbackFn *fn, const void *privdata);
+void redisSetDisconnectCallback(redisContext *c, redisContextCallbackFn *fn, void *privdata);
/* The command callback is called every time redisCommand() is called in a
* non-blocking context. It is called *after* the formatted command has been
* appended to the write buffer. */
-void redisSetCommandCallback(redisContext *c, redisContextCallbackFn *fn, const void *privdata);
+void redisSetCommandCallback(redisContext *c, redisContextCallbackFn *fn, void *privdata);
/* The free callback is called *before* all allocations are free'd. Use it to
* release resources that depend/use the redisContext that is being free'd. */
-void redisSetFreeCallback(redisContext *c, redisContextCallbackFn *fn, const void *privdata);
+void redisSetFreeCallback(redisContext *c, redisContextCallbackFn *fn, void *privdata);
/* Issue a command to Redis. In a blocking context, it returns the reply. When
* an error occurs, it returns NULL and you should read redisContext->error
diff --git a/test.c b/test.c
index b1a6ed6..cbf8149 100644
--- a/test.c
+++ b/test.c
@@ -195,7 +195,7 @@ static void cleanup() {
}
static long __test_callback_flags = 0;
-static void __test_callback(redisContext *c, const void *privdata) {
+static void __test_callback(redisContext *c, void *privdata) {
((void)c);
/* Shift to detect execution order */
__test_callback_flags <<= 8;
@@ -218,7 +218,7 @@ static void test_nonblocking_connection() {
__test_callback_flags = 0;
test("Calls command callback when command is issued: ");
c = redisConnectNonBlock("127.0.0.1", 6379, NULL);
- redisSetCommandCallback(c,__test_callback,(const void*)1);
+ redisSetCommandCallback(c,__test_callback,(void*)1);
redisCommand(c,"PING");
test_cond(__test_callback_flags == 1);
redisFree(c);
@@ -226,7 +226,7 @@ static void test_nonblocking_connection() {
__test_callback_flags = 0;
test("Calls disconnect callback on redisDisconnect: ");
c = redisConnectNonBlock("127.0.0.1", 6379, NULL);
- redisSetDisconnectCallback(c,__test_callback,(const void*)2);
+ redisSetDisconnectCallback(c,__test_callback,(void*)2);
redisDisconnect(c);
test_cond(__test_callback_flags == 2);
redisFree(c);
@@ -234,8 +234,8 @@ static void test_nonblocking_connection() {
__test_callback_flags = 0;
test("Calls disconnect callback and free callback on redisFree: ");
c = redisConnectNonBlock("127.0.0.1", 6379, NULL);
- redisSetDisconnectCallback(c,__test_callback,(const void*)2);
- redisSetFreeCallback(c,__test_callback,(const void*)4);
+ redisSetDisconnectCallback(c,__test_callback,(void*)2);
+ redisSetFreeCallback(c,__test_callback,(void*)4);
redisFree(c);
test_cond(__test_callback_flags == ((2 << 8) | 4));
@@ -262,9 +262,9 @@ static void test_nonblocking_connection() {
wdone = __test_reply_callback_flags = 0;
test("Process callbacks in the right sequence: ");
c = redisConnectNonBlock("127.0.0.1", 6379, NULL);
- redisCommandWithCallback(c,__test_reply_callback,(const void*)1,"PING");
- redisCommandWithCallback(c,__test_reply_callback,(const void*)2,"PING");
- redisCommandWithCallback(c,__test_reply_callback,(const void*)3,"PING");
+ redisCommandWithCallback(c,__test_reply_callback,(void*)1,"PING");
+ redisCommandWithCallback(c,__test_reply_callback,(void*)2,"PING");
+ redisCommandWithCallback(c,__test_reply_callback,(void*)3,"PING");
/* Write output buffer */
while(!wdone) {