Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f9717aed44 | ||
|
|
0b6669cde3 | ||
|
|
a153788613 |
60
CHANGELOG.md
60
CHANGELOG.md
@ -1,21 +1,59 @@
|
|||||||
### 1.0.0 (unreleased)
|
**NOTE: BREAKING CHANGES upgrading from 0.13.x to 0.14.x **:
|
||||||
|
|
||||||
**Fixes**:
|
|
||||||
|
|
||||||
* Catch a buffer overflow when formatting the error message
|
|
||||||
* Import latest upstream sds. This breaks applications that are linked against the old hiredis v0.13
|
|
||||||
* Fix warnings, when compiled with -Wshadow
|
|
||||||
* Make hiredis compile in Cygwin on Windows, now CI-tested
|
|
||||||
* Bulk and multi-bulk lengths less than -1 or greater than `LLONG_MAX` are now
|
* Bulk and multi-bulk lengths less than -1 or greater than `LLONG_MAX` are now
|
||||||
protocol errors. This is consistent with the RESP specification. On 32-bit
|
protocol errors. This is consistent with the RESP specification. On 32-bit
|
||||||
platforms, the upper bound is lowered to `SIZE_MAX`.
|
platforms, the upper bound is lowered to `SIZE_MAX`.
|
||||||
|
|
||||||
**BREAKING CHANGES**:
|
|
||||||
|
|
||||||
* Change `redisReply.len` to `size_t`, as it denotes the the size of a string
|
* Change `redisReply.len` to `size_t`, as it denotes the the size of a string
|
||||||
|
|
||||||
User code should compare this to `size_t` values as well.
|
User code should compare this to `size_t` values as well. If it was used to
|
||||||
If it was used to compare to other values, casting might be necessary or can be removed, if casting was applied before.
|
compare to other values, casting might be necessary or can be removed, if
|
||||||
|
casting was applied before.
|
||||||
|
|
||||||
|
### 0.14.1 (2020-03-13)
|
||||||
|
|
||||||
|
* Adds safe allocation wrappers (CVE-2020-7105, #747, #752) (Michael Grunder)
|
||||||
|
|
||||||
|
### 0.14.0 (2018-09-25)
|
||||||
|
|
||||||
|
* Make string2ll static to fix conflict with Redis (Tom Lee [c3188b])
|
||||||
|
* Use -dynamiclib instead of -shared for OSX (Ryan Schmidt [a65537])
|
||||||
|
* Use string2ll from Redis w/added tests (Michael Grunder [7bef04, 60f622])
|
||||||
|
* Makefile - OSX compilation fixes (Ryan Schmidt [881fcb, 0e9af8])
|
||||||
|
* Remove redundant NULL checks (Justin Brewer [54acc8, 58e6b8])
|
||||||
|
* Fix bulk and multi-bulk length truncation (Justin Brewer [109197])
|
||||||
|
* Fix SIGSEGV in OpenBSD by checking for NULL before calling freeaddrinfo (Justin Brewer [546d94])
|
||||||
|
* Several POSIX compatibility fixes (Justin Brewer [bbeab8, 49bbaa, d1c1b6])
|
||||||
|
* Makefile - Compatibility fixes (Dimitri Vorobiev [3238cf, 12a9d1])
|
||||||
|
* Makefile - Fix make install on FreeBSD (Zach Shipko [a2ef2b])
|
||||||
|
* Makefile - don't assume $(INSTALL) is cp (Igor Gnatenko [725a96])
|
||||||
|
* Separate side-effect causing function from assert and small cleanup (amallia [b46413, 3c3234])
|
||||||
|
* Don't send negative values to `__redisAsyncCommand` (Frederik Deweerdt [706129])
|
||||||
|
* Fix leak if setsockopt fails (Frederik Deweerdt [e21c9c])
|
||||||
|
* Fix libevent leak (zfz [515228])
|
||||||
|
* Clean up GCC warning (Ichito Nagata [2ec774])
|
||||||
|
* Keep track of errno in `__redisSetErrorFromErrno()` as snprintf may use it (Jin Qing [25cd88])
|
||||||
|
* Solaris compilation fix (Donald Whyte [41b07d])
|
||||||
|
* Reorder linker arguments when building examples (Tustfarm-heart [06eedd])
|
||||||
|
* Keep track of subscriptions in case of rapid subscribe/unsubscribe (Hyungjin Kim [073dc8, be76c5, d46999])
|
||||||
|
* libuv use after free fix (Paul Scott [cbb956])
|
||||||
|
* Properly close socket fd on reconnect attempt (WSL [64d1ec])
|
||||||
|
* Skip valgrind in OSX tests (Jan-Erik Rediger [9deb78])
|
||||||
|
* Various updates for Travis testing OSX (Ted Nyman [fa3774, 16a459, bc0ea5])
|
||||||
|
* Update libevent (Chris Xin [386802])
|
||||||
|
* Change sds.h for building in C++ projects (Ali Volkan ATLI [f5b32e])
|
||||||
|
* Use proper format specifier in redisFormatSdsCommandArgv (Paulino Huerta, Jan-Erik Rediger [360a06, 8655a6])
|
||||||
|
* Better handling of NULL reply in example code (Jan-Erik Rediger [1b8ed3])
|
||||||
|
* Prevent overflow when formatting an error (Jan-Erik Rediger [0335cb])
|
||||||
|
* Compatibility fix for strerror_r (Tom Lee [bb1747])
|
||||||
|
* Properly detect integer parse/overflow errors (Justin Brewer [93421f])
|
||||||
|
* Adds CI for Windows and cygwin fixes (owent, [6c53d6, 6c3e40])
|
||||||
|
* Catch a buffer overflow when formatting the error message
|
||||||
|
* Import latest upstream sds. This breaks applications that are linked against the old hiredis v0.13
|
||||||
|
* Fix warnings, when compiled with -Wshadow
|
||||||
|
* Make hiredis compile in Cygwin on Windows, now CI-tested
|
||||||
|
|
||||||
|
**BREAKING CHANGES**:
|
||||||
|
|
||||||
* Remove backwards compatibility macro's
|
* Remove backwards compatibility macro's
|
||||||
|
|
||||||
|
|||||||
17
Makefile
17
Makefile
@ -3,7 +3,7 @@
|
|||||||
# Copyright (C) 2010-2011 Pieter Noordhuis <pcnoordhuis at gmail dot com>
|
# Copyright (C) 2010-2011 Pieter Noordhuis <pcnoordhuis at gmail dot com>
|
||||||
# This file is released under the BSD license, see the COPYING file
|
# This file is released under the BSD license, see the COPYING file
|
||||||
|
|
||||||
OBJ=net.o hiredis.o sds.o async.o read.o
|
OBJ=net.o hiredis.o sds.o async.o read.o alloc.o
|
||||||
EXAMPLES=hiredis-example hiredis-example-libevent hiredis-example-libev hiredis-example-glib
|
EXAMPLES=hiredis-example hiredis-example-libevent hiredis-example-libev hiredis-example-glib
|
||||||
TESTS=hiredis-test
|
TESTS=hiredis-test
|
||||||
LIBNAME=libhiredis
|
LIBNAME=libhiredis
|
||||||
@ -68,13 +68,14 @@ endif
|
|||||||
all: $(DYLIBNAME) $(STLIBNAME) hiredis-test $(PKGCONFNAME)
|
all: $(DYLIBNAME) $(STLIBNAME) hiredis-test $(PKGCONFNAME)
|
||||||
|
|
||||||
# Deps (use make dep to generate this)
|
# Deps (use make dep to generate this)
|
||||||
async.o: async.c fmacros.h async.h hiredis.h read.h sds.h net.h dict.c dict.h
|
alloc.o: alloc.c fmacros.h alloc.h
|
||||||
dict.o: dict.c fmacros.h dict.h
|
async.o: async.c fmacros.h alloc.h async.h hiredis.h read.h sds.h net.h dict.c dict.h
|
||||||
hiredis.o: hiredis.c fmacros.h hiredis.h read.h sds.h net.h
|
dict.o: dict.c fmacros.h alloc.h dict.h
|
||||||
net.o: net.c fmacros.h net.h hiredis.h read.h sds.h
|
hiredis.o: hiredis.c fmacros.h hiredis.h read.h sds.h alloc.h net.h
|
||||||
|
net.o: net.c fmacros.h net.h hiredis.h read.h sds.h alloc.h
|
||||||
read.o: read.c fmacros.h read.h sds.h
|
read.o: read.c fmacros.h read.h sds.h
|
||||||
sds.o: sds.c sds.h
|
sds.o: sds.c sds.h sdsalloc.h
|
||||||
test.o: test.c fmacros.h hiredis.h read.h sds.h
|
test.o: test.c fmacros.h hiredis.h read.h sds.h alloc.h net.h
|
||||||
|
|
||||||
$(DYLIBNAME): $(OBJ)
|
$(DYLIBNAME): $(OBJ)
|
||||||
$(DYLIB_MAKE_CMD) $(OBJ)
|
$(DYLIB_MAKE_CMD) $(OBJ)
|
||||||
@ -177,7 +178,7 @@ $(PKGCONFNAME): hiredis.h
|
|||||||
|
|
||||||
install: $(DYLIBNAME) $(STLIBNAME) $(PKGCONFNAME)
|
install: $(DYLIBNAME) $(STLIBNAME) $(PKGCONFNAME)
|
||||||
mkdir -p $(INSTALL_INCLUDE_PATH) $(INSTALL_INCLUDE_PATH)/adapters $(INSTALL_LIBRARY_PATH)
|
mkdir -p $(INSTALL_INCLUDE_PATH) $(INSTALL_INCLUDE_PATH)/adapters $(INSTALL_LIBRARY_PATH)
|
||||||
$(INSTALL) hiredis.h async.h read.h sds.h $(INSTALL_INCLUDE_PATH)
|
$(INSTALL) hiredis.h async.h read.h sds.h alloc.h $(INSTALL_INCLUDE_PATH)
|
||||||
$(INSTALL) adapters/*.h $(INSTALL_INCLUDE_PATH)/adapters
|
$(INSTALL) adapters/*.h $(INSTALL_INCLUDE_PATH)/adapters
|
||||||
$(INSTALL) $(DYLIBNAME) $(INSTALL_LIBRARY_PATH)/$(DYLIB_MINOR_NAME)
|
$(INSTALL) $(DYLIBNAME) $(INSTALL_LIBRARY_PATH)/$(DYLIB_MINOR_NAME)
|
||||||
cd $(INSTALL_LIBRARY_PATH) && ln -sf $(DYLIB_MINOR_NAME) $(DYLIBNAME)
|
cd $(INSTALL_LIBRARY_PATH) && ln -sf $(DYLIB_MINOR_NAME) $(DYLIBNAME)
|
||||||
|
|||||||
23
README.md
23
README.md
@ -1,6 +1,6 @@
|
|||||||
[](https://travis-ci.org/redis/hiredis)
|
[](https://travis-ci.org/redis/hiredis)
|
||||||
|
|
||||||
**This Readme reflects the latest changed in the master branch. See [v0.13.3](https://github.com/redis/hiredis/tree/v0.13.3) for the Readme and documentation for the latest release.**
|
**This Readme reflects the latest changed in the master branch. See [v0.14.1](https://github.com/redis/hiredis/tree/v0.14.1) for the Readme and documentation for the latest release.**
|
||||||
|
|
||||||
# HIREDIS
|
# HIREDIS
|
||||||
|
|
||||||
@ -22,20 +22,19 @@ Redis version >= 1.2.0.
|
|||||||
The library comes with multiple APIs. There is the
|
The library comes with multiple APIs. There is the
|
||||||
*synchronous API*, the *asynchronous API* and the *reply parsing API*.
|
*synchronous API*, the *asynchronous API* and the *reply parsing API*.
|
||||||
|
|
||||||
## Upgrading to `1.0.0`
|
## IMPORTANT: Breaking changes when upgrading from 0.13.x -> 0.14.x
|
||||||
|
|
||||||
Version 1.0.0 marks a stable release of hiredis.
|
Bulk and multi-bulk lengths less than -1 or greater than `LLONG_MAX` are now
|
||||||
It includes some minor breaking changes, mostly to make the exposed API more uniform and self-explanatory.
|
protocol errors. This is consistent with the RESP specification. On 32-bit
|
||||||
It also bundles the updated `sds` library, to sync up with upstream and Redis.
|
platforms, the upper bound is lowered to `SIZE_MAX`.
|
||||||
For most applications a recompile against the new hiredis should be enough.
|
|
||||||
For code changes see the [Changelog](CHANGELOG.md).
|
|
||||||
|
|
||||||
## Upgrading from `<0.9.0`
|
Change `redisReply.len` to `size_t`, as it denotes the the size of a string
|
||||||
|
|
||||||
Version 0.9.0 is a major overhaul of hiredis in every aspect. However, upgrading existing
|
User code should compare this to `size_t` values as well. If it was used to
|
||||||
code using hiredis should not be a big pain. The key thing to keep in mind when
|
compare to other values, casting might be necessary or can be removed, if
|
||||||
upgrading is that hiredis >= 0.9.0 uses a `redisContext*` to keep state, in contrast to
|
casting was applied before.
|
||||||
the stateless 0.0.1 that only has a file descriptor to work with.
|
|
||||||
|
For a detailed list of changes please view our [Changelog](CHANGELOG.md).
|
||||||
|
|
||||||
## Synchronous API
|
## Synchronous API
|
||||||
|
|
||||||
|
|||||||
@ -108,7 +108,7 @@ static int redisAeAttach(aeEventLoop *loop, redisAsyncContext *ac) {
|
|||||||
return REDIS_ERR;
|
return REDIS_ERR;
|
||||||
|
|
||||||
/* Create container for context and r/w events */
|
/* Create container for context and r/w events */
|
||||||
e = (redisAeEvents*)malloc(sizeof(*e));
|
e = (redisAeEvents*)hi_malloc(sizeof(*e));
|
||||||
e->context = ac;
|
e->context = ac;
|
||||||
e->loop = loop;
|
e->loop = loop;
|
||||||
e->fd = c->fd;
|
e->fd = c->fd;
|
||||||
|
|||||||
@ -55,7 +55,7 @@ static int redisIvykisAttach(redisAsyncContext *ac) {
|
|||||||
return REDIS_ERR;
|
return REDIS_ERR;
|
||||||
|
|
||||||
/* Create container for context and r/w events */
|
/* Create container for context and r/w events */
|
||||||
e = (redisIvykisEvents*)malloc(sizeof(*e));
|
e = (redisIvykisEvents*)hi_malloc(sizeof(*e));
|
||||||
e->context = ac;
|
e->context = ac;
|
||||||
|
|
||||||
/* Register functions to start/stop listening for events */
|
/* Register functions to start/stop listening for events */
|
||||||
|
|||||||
@ -119,7 +119,7 @@ static int redisLibevAttach(EV_P_ redisAsyncContext *ac) {
|
|||||||
return REDIS_ERR;
|
return REDIS_ERR;
|
||||||
|
|
||||||
/* Create container for context and r/w events */
|
/* Create container for context and r/w events */
|
||||||
e = (redisLibevEvents*)malloc(sizeof(*e));
|
e = (redisLibevEvents*)hi_malloc(sizeof(*e));
|
||||||
e->context = ac;
|
e->context = ac;
|
||||||
#if EV_MULTIPLICITY
|
#if EV_MULTIPLICITY
|
||||||
e->loop = loop;
|
e->loop = loop;
|
||||||
|
|||||||
@ -87,7 +87,7 @@ static int redisLibeventAttach(redisAsyncContext *ac, struct event_base *base) {
|
|||||||
return REDIS_ERR;
|
return REDIS_ERR;
|
||||||
|
|
||||||
/* Create container for context and r/w events */
|
/* Create container for context and r/w events */
|
||||||
e = (redisLibeventEvents*)malloc(sizeof(*e));
|
e = (redisLibeventEvents*)hi_calloc(1, sizeof(*e));
|
||||||
e->context = ac;
|
e->context = ac;
|
||||||
|
|
||||||
/* Register functions to start/stop listening for events */
|
/* Register functions to start/stop listening for events */
|
||||||
|
|||||||
65
alloc.c
Normal file
65
alloc.c
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2020, Michael Grunder <michael dot grunder at gmail dot com>
|
||||||
|
*
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of Redis nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without
|
||||||
|
* specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "fmacros.h"
|
||||||
|
#include "alloc.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
void *hi_malloc(size_t size) {
|
||||||
|
void *ptr = malloc(size);
|
||||||
|
if (ptr == NULL)
|
||||||
|
HIREDIS_OOM_HANDLER;
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *hi_calloc(size_t nmemb, size_t size) {
|
||||||
|
void *ptr = calloc(nmemb, size);
|
||||||
|
if (ptr == NULL)
|
||||||
|
HIREDIS_OOM_HANDLER;
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *hi_realloc(void *ptr, size_t size) {
|
||||||
|
void *newptr = realloc(ptr, size);
|
||||||
|
if (newptr == NULL)
|
||||||
|
HIREDIS_OOM_HANDLER;
|
||||||
|
|
||||||
|
return newptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *hi_strdup(const char *str) {
|
||||||
|
char *newstr = strdup(str);
|
||||||
|
if (newstr == NULL)
|
||||||
|
HIREDIS_OOM_HANDLER;
|
||||||
|
|
||||||
|
return newstr;
|
||||||
|
}
|
||||||
53
alloc.h
Normal file
53
alloc.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2020, Michael Grunder <michael dot grunder at gmail dot com>
|
||||||
|
*
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of Redis nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without
|
||||||
|
* specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HIREDIS_ALLOC_H
|
||||||
|
#define HIREDIS_ALLOC_H
|
||||||
|
|
||||||
|
#include <stdlib.h> /* for size_t */
|
||||||
|
|
||||||
|
#ifndef HIREDIS_OOM_HANDLER
|
||||||
|
#define HIREDIS_OOM_HANDLER abort()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void *hi_malloc(size_t size);
|
||||||
|
void *hi_calloc(size_t nmemb, size_t size);
|
||||||
|
void *hi_realloc(void *ptr, size_t size);
|
||||||
|
char *hi_strdup(const char *str);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* HIREDIS_ALLOC_H */
|
||||||
3
async.c
3
async.c
@ -30,6 +30,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "fmacros.h"
|
#include "fmacros.h"
|
||||||
|
#include "alloc.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
@ -68,7 +69,7 @@ static unsigned int callbackHash(const void *key) {
|
|||||||
|
|
||||||
static void *callbackValDup(void *privdata, const void *src) {
|
static void *callbackValDup(void *privdata, const void *src) {
|
||||||
((void) privdata);
|
((void) privdata);
|
||||||
redisCallback *dup = malloc(sizeof(*dup));
|
redisCallback *dup = hi_malloc(sizeof(*dup));
|
||||||
memcpy(dup,src,sizeof(*dup));
|
memcpy(dup,src,sizeof(*dup));
|
||||||
return dup;
|
return dup;
|
||||||
}
|
}
|
||||||
|
|||||||
7
dict.c
7
dict.c
@ -34,6 +34,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "fmacros.h"
|
#include "fmacros.h"
|
||||||
|
#include "alloc.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
@ -71,7 +72,7 @@ static void _dictReset(dict *ht) {
|
|||||||
|
|
||||||
/* Create a new hash table */
|
/* Create a new hash table */
|
||||||
static dict *dictCreate(dictType *type, void *privDataPtr) {
|
static dict *dictCreate(dictType *type, void *privDataPtr) {
|
||||||
dict *ht = malloc(sizeof(*ht));
|
dict *ht = hi_malloc(sizeof(*ht));
|
||||||
_dictInit(ht,type,privDataPtr);
|
_dictInit(ht,type,privDataPtr);
|
||||||
return ht;
|
return ht;
|
||||||
}
|
}
|
||||||
@ -142,7 +143,7 @@ static int dictAdd(dict *ht, void *key, void *val) {
|
|||||||
return DICT_ERR;
|
return DICT_ERR;
|
||||||
|
|
||||||
/* Allocates the memory and stores key */
|
/* Allocates the memory and stores key */
|
||||||
entry = malloc(sizeof(*entry));
|
entry = hi_malloc(sizeof(*entry));
|
||||||
entry->next = ht->table[index];
|
entry->next = ht->table[index];
|
||||||
ht->table[index] = entry;
|
ht->table[index] = entry;
|
||||||
|
|
||||||
@ -256,7 +257,7 @@ static dictEntry *dictFind(dict *ht, const void *key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static dictIterator *dictGetIterator(dict *ht) {
|
static dictIterator *dictGetIterator(dict *ht) {
|
||||||
dictIterator *iter = malloc(sizeof(*iter));
|
dictIterator *iter = hi_malloc(sizeof(*iter));
|
||||||
|
|
||||||
iter->ht = ht;
|
iter->ht = ht;
|
||||||
iter->index = -1;
|
iter->index = -1;
|
||||||
|
|||||||
@ -38,10 +38,11 @@
|
|||||||
#include <sys/time.h> /* for struct timeval */
|
#include <sys/time.h> /* for struct timeval */
|
||||||
#include <stdint.h> /* uintXX_t, etc */
|
#include <stdint.h> /* uintXX_t, etc */
|
||||||
#include "sds.h" /* for sds */
|
#include "sds.h" /* for sds */
|
||||||
|
#include "alloc.h" /* for allocation wrappers */
|
||||||
|
|
||||||
#define HIREDIS_MAJOR 0
|
#define HIREDIS_MAJOR 0
|
||||||
#define HIREDIS_MINOR 14
|
#define HIREDIS_MINOR 14
|
||||||
#define HIREDIS_PATCH 0
|
#define HIREDIS_PATCH 1
|
||||||
#define HIREDIS_SONAME 0.14
|
#define HIREDIS_SONAME 0.14
|
||||||
|
|
||||||
/* Connection type can be blocking or non-blocking and is set in the
|
/* Connection type can be blocking or non-blocking and is set in the
|
||||||
|
|||||||
10
net.c
10
net.c
@ -287,13 +287,13 @@ static int _redisContextConnectTcp(redisContext *c, const char *addr, int port,
|
|||||||
if (c->tcp.host != addr) {
|
if (c->tcp.host != addr) {
|
||||||
free(c->tcp.host);
|
free(c->tcp.host);
|
||||||
|
|
||||||
c->tcp.host = strdup(addr);
|
c->tcp.host = hi_strdup(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeout) {
|
if (timeout) {
|
||||||
if (c->timeout != timeout) {
|
if (c->timeout != timeout) {
|
||||||
if (c->timeout == NULL)
|
if (c->timeout == NULL)
|
||||||
c->timeout = malloc(sizeof(struct timeval));
|
c->timeout = hi_malloc(sizeof(struct timeval));
|
||||||
|
|
||||||
memcpy(c->timeout, timeout, sizeof(struct timeval));
|
memcpy(c->timeout, timeout, sizeof(struct timeval));
|
||||||
}
|
}
|
||||||
@ -312,7 +312,7 @@ static int _redisContextConnectTcp(redisContext *c, const char *addr, int port,
|
|||||||
c->tcp.source_addr = NULL;
|
c->tcp.source_addr = NULL;
|
||||||
} else if (c->tcp.source_addr != source_addr) {
|
} else if (c->tcp.source_addr != source_addr) {
|
||||||
free(c->tcp.source_addr);
|
free(c->tcp.source_addr);
|
||||||
c->tcp.source_addr = strdup(source_addr);
|
c->tcp.source_addr = hi_strdup(source_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(_port, 6, "%d", port);
|
snprintf(_port, 6, "%d", port);
|
||||||
@ -440,12 +440,12 @@ int redisContextConnectUnix(redisContext *c, const char *path, const struct time
|
|||||||
|
|
||||||
c->connection_type = REDIS_CONN_UNIX;
|
c->connection_type = REDIS_CONN_UNIX;
|
||||||
if (c->unix_sock.path != path)
|
if (c->unix_sock.path != path)
|
||||||
c->unix_sock.path = strdup(path);
|
c->unix_sock.path = hi_strdup(path);
|
||||||
|
|
||||||
if (timeout) {
|
if (timeout) {
|
||||||
if (c->timeout != timeout) {
|
if (c->timeout != timeout) {
|
||||||
if (c->timeout == NULL)
|
if (c->timeout == NULL)
|
||||||
c->timeout = malloc(sizeof(struct timeval));
|
c->timeout = hi_malloc(sizeof(struct timeval));
|
||||||
|
|
||||||
memcpy(c->timeout, timeout, sizeof(struct timeval));
|
memcpy(c->timeout, timeout, sizeof(struct timeval));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user