Permalink
Browse files

Update hiredis to 0.10 and change code accordingly

  • Loading branch information...
pietern committed May 17, 2011
1 parent 320dd88 commit fc234bb8d01e030772fc02266f1e9ca5ad5a6add
Showing with 15 additions and 18 deletions.
  1. +1 −1 ext/hiredis_ext/connection.c
  2. +1 −1 ext/hiredis_ext/extconf.rb
  3. +12 −15 ext/hiredis_ext/reader.c
  4. +1 −1 vendor/hiredis
@@ -80,7 +80,7 @@ static VALUE connection_generic_connect(VALUE self, redisContext *c) {
}
}
- redisSetReplyObjectFunctions(c,&redisExtReplyObjectFunctions);
+ c->reader->fn = &redisExtReplyObjectFunctions;
pc->context = c;
return Qnil;
}
@@ -17,5 +17,5 @@ def need_library(*args)
system("cd #{bundled_hiredis_dir} && make static") if File.directory?(bundled_hiredis_dir)
need_header('hiredis.h')
-need_library('hiredis', 'redisReplyReaderCreate')
+need_library('hiredis', 'redisReaderCreate')
create_makefile('hiredis/ext/hiredis_ext')
View
@@ -61,38 +61,35 @@ redisReplyObjectFunctions redisExtReplyObjectFunctions = {
freeObject
};
-static void reader_mark(void *reader) {
- VALUE root;
- root = (VALUE)redisReplyReaderGetObject(reader);
+static void reader_mark(redisReader *reader) {
+ VALUE root = (VALUE)reader->reply;
if (root != 0 && TYPE(root) == T_ARRAY) rb_gc_mark(root);
}
static VALUE reader_allocate(VALUE klass) {
- void *reader = redisReplyReaderCreate();
- redisReplyReaderSetReplyObjectFunctions(reader,&redisExtReplyObjectFunctions);
- return Data_Wrap_Struct(klass, reader_mark, redisReplyReaderFree, reader);
+ redisReader *reader = redisReaderCreate();
+ reader->fn = &redisExtReplyObjectFunctions;
+ return Data_Wrap_Struct(klass, reader_mark, redisReaderFree, reader);
}
static VALUE reader_feed(VALUE klass, VALUE str) {
- void *reader;
+ redisReader *reader;
if (TYPE(str) != T_STRING)
rb_raise(rb_eTypeError, "not a string");
- Data_Get_Struct(klass, void, reader);
- redisReplyReaderFeed(reader,RSTRING_PTR(str),(size_t)RSTRING_LEN(str));
+ Data_Get_Struct(klass, redisReader, reader);
+ redisReaderFeed(reader,RSTRING_PTR(str),(size_t)RSTRING_LEN(str));
return INT2NUM(0);
}
static VALUE reader_gets(VALUE klass) {
- void *reader;
+ redisReader *reader;
VALUE reply;
- Data_Get_Struct(klass, void, reader);
- if (redisReplyReaderGetReply(reader,(void**)&reply) != REDIS_OK) {
- char *errstr = redisReplyReaderGetError(reader);
- rb_raise(rb_eRuntimeError,"%s",errstr);
- }
+ Data_Get_Struct(klass, redisReader, reader);
+ if (redisReaderGetReply(reader,(void**)&reply) != REDIS_OK)
+ rb_raise(rb_eRuntimeError,"%s",reader->errstr);
return reply;
}

0 comments on commit fc234bb

Please sign in to comment.