int anetTcpConnect(char *err, char *addr, int port);
int anetTcpNonBlockConnect(char *err, char *addr, int port);
-int anetRead(int fd, void *buf, int count);
+int anetRead(int fd, char *buf, int count);
int anetResolve(char *err, char *host, char *ipbuf);
int anetTcpServer(char *err, int port, char *bindaddr);
int anetAccept(char *err, int serversock, char *ip, int *port);
-int anetWrite(int fd, void *buf, int count);
+int anetWrite(int fd, char *buf, int count);
int anetNonBlock(char *err, int fd);
int anetTcpNoDelay(char *err, int fd);
int anetTcpKeepAlive(char *err, int fd);
* 00|000000 => if the two MSB are 00 the len is the 6 bits of this byte
* 01|000000 00000000 => 01, the len is 14 byes, 6 bits + 8 bits of next byte
* 10|000000 [32 bit integer] => if it's 01, a full 32 bit len will follow
- * 11|000000 reserved for future uses
+ * 11|000000 this means: specially encoded object will follow. The six bits
+ * number specify the kind of object that follows.
+ * See the REDIS_RDB_ENC_* defines.
*
* Lenghts up to 63 are stored using a single byte, most DB keys, and may
* values, will fit inside. */
#define REDIS_RDB_64BITLEN 3
#define REDIS_RDB_LENERR UINT_MAX
+/* When a length of a string object stored on disk has the first two bits
+ * set, the remaining two bits specify a special encoding for the object
+ * accordingly to the following defines: */
+#define REDIS_RDB_ENC_INT8 0 /* 8 bit signed integer */
+#define REDIS_RDB_ENC_INT16 1 /* 16 bit signed integer */
+#define REDIS_RDB_ENC_INT32 2 /* 32 bit signed integer */
+#define REDIS_RDB_ENC_FLZ 3 /* string compressed with FASTLZ */
+
/* Client flags */
#define REDIS_CLOSE 1 /* This client connection should be closed ASAP */
#define REDIS_SLAVE 2 /* This client is a slave server */
used = dictGetHashTableUsed(server.dict[j]);
if (!(loops % 5) && used > 0) {
redisLog(REDIS_DEBUG,"DB %d: %d keys in %d slots HT.",j,used,size);
- // dictPrintStats(server.dict);
+ /* dictPrintStats(server.dict); */
}
if (size && used && size > REDIS_HT_MINSLOTS &&
(used*100/size < REDIS_HT_MINFILL)) {
if (c->flags & REDIS_MASTER) {
nwritten = objlen - c->sentlen;
} else {
- nwritten = write(fd, o->ptr+c->sentlen, objlen - c->sentlen);
+ nwritten = write(fd, ((char*)o->ptr)+c->sentlen, objlen - c->sentlen);
if (nwritten <= 0) break;
}
c->sentlen += nwritten;
}
static void setCommand(redisClient *c) {
- return setGenericCommand(c,0);
+ setGenericCommand(c,0);
}
static void setnxCommand(redisClient *c) {
- return setGenericCommand(c,1);
+ setGenericCommand(c,1);
}
static void getCommand(redisClient *c) {
}
static void incrCommand(redisClient *c) {
- return incrDecrCommand(c,1);
+ incrDecrCommand(c,1);
}
static void decrCommand(redisClient *c) {
- return incrDecrCommand(c,-1);
+ incrDecrCommand(c,-1);
}
static void incrbyCommand(redisClient *c) {
int incr = atoi(c->argv[2]->ptr);
- return incrDecrCommand(c,incr);
+ incrDecrCommand(c,incr);
}
static void decrbyCommand(redisClient *c) {
int incr = atoi(c->argv[2]->ptr);
- return incrDecrCommand(c,-incr);
+ incrDecrCommand(c,-incr);
}
/* ========================= Type agnostic commands ========================= */
}
ln = fromtail ? list->tail : list->head;
while (ln) {
- next = fromtail ? ln->prev : ln->next;
robj *ele = listNodeValue(ln);
+
+ next = fromtail ? ln->prev : ln->next;
if (sdscmp(ele->ptr,c->argv[3]->ptr) == 0) {
listDelNode(list,ln);
server.dirty++;
keyobj.ptr = ((char*)&keyname)+(sizeof(long)*2);
de = dictFind(dict,&keyobj);
- // printf("lookup '%s' => %p\n", keyname.buf,de);
+ /* printf("lookup '%s' => %p\n", keyname.buf,de); */
if (!de) return NULL;
return dictGetEntryVal(de);
}
return REDIS_OK;
}
-static int syncWrite(int fd, void *ptr, ssize_t size, int timeout) {
+static int syncWrite(int fd, char *ptr, ssize_t size, int timeout) {
ssize_t nwritten, ret = size;
time_t start = time(NULL);
return ret;
}
-static int syncRead(int fd, void *ptr, ssize_t size, int timeout) {
+static int syncRead(int fd, char *ptr, ssize_t size, int timeout) {
ssize_t nread, totread = 0;
time_t start = time(NULL);
*((size_t*)ptr) = size;
used_memory += size+sizeof(size_t);
- return ptr+sizeof(size_t);
+ return (char*)ptr+sizeof(size_t);
}
void *zrealloc(void *ptr, size_t size) {
void *newptr;
if (ptr == NULL) return zmalloc(size);
- realptr = ptr-sizeof(size_t);
+ realptr = (char*)ptr-sizeof(size_t);
oldsize = *((size_t*)realptr);
newptr = realloc(realptr,size+sizeof(size_t));
if (!newptr) return NULL;
*((size_t*)newptr) = size;
used_memory -= oldsize;
used_memory += size;
- return newptr+sizeof(size_t);
+ return (char*)newptr+sizeof(size_t);
}
void zfree(void *ptr) {
size_t oldsize;
if (ptr == NULL) return;
- realptr = ptr-sizeof(size_t);
+ realptr = (char*)ptr-sizeof(size_t);
oldsize = *((size_t*)realptr);
used_memory -= oldsize+sizeof(size_t);
free(realptr);