From 936c4ab64bde3c781e965a7e68b154bbd8891e6e Mon Sep 17 00:00:00 2001 From: antirez Date: Thu, 2 Jun 2011 17:41:42 +0200 Subject: [PATCH] touch less pages in decrRefCount --- src/object.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/object.c b/src/object.c index 22f53837..20e7f57a 100644 --- a/src/object.c +++ b/src/object.c @@ -180,7 +180,7 @@ void decrRefCount(void *obj) { robj *o = obj; if (o->refcount <= 0) redisPanic("decrRefCount against refcount <= 0"); - if (--(o->refcount) == 0) { + if (o->refcount == 1) { switch(o->type) { case REDIS_STRING: freeStringObject(o); break; case REDIS_LIST: freeListObject(o); break; @@ -189,8 +189,9 @@ void decrRefCount(void *obj) { case REDIS_HASH: freeHashObject(o); break; default: redisPanic("Unknown object type"); break; } - o->ptr = NULL; /* defensive programming. We'll see NULL in traces. */ zfree(o); + } else { + o->refcount--; } }