Skip to content
This repository has been archived by the owner on Jul 24, 2019. It is now read-only.

Commit

Permalink
Fix for PHP-trunk (5.4)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasff committed Jan 19, 2011
1 parent 0a8c7fa commit 04d6237
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions library.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1092,7 +1092,11 @@ PHPAPI void redis_free_socket(RedisSock *redis_sock)


PHPAPI int PHPAPI int
redis_serialize(RedisSock *redis_sock, zval *z, char **val, int *val_len TSRMLS_CC) { redis_serialize(RedisSock *redis_sock, zval *z, char **val, int *val_len TSRMLS_CC) {
#if ZEND_MODULE_API_NO >= 20100000
php_serialize_data_t ht;
#else
HashTable ht; HashTable ht;
#endif
smart_str sstr = {0}; smart_str sstr = {0};
zval *z_copy; zval *z_copy;
size_t sz; size_t sz;
Expand Down Expand Up @@ -1133,11 +1137,17 @@ redis_serialize(RedisSock *redis_sock, zval *z, char **val, int *val_len TSRMLS_


case REDIS_SERIALIZER_PHP: case REDIS_SERIALIZER_PHP:


#if ZEND_MODULE_API_NO >= 20100000
#else
zend_hash_init(&ht, 10, NULL, NULL, 0); zend_hash_init(&ht, 10, NULL, NULL, 0);
#endif
php_var_serialize(&sstr, &z, &ht TSRMLS_CC); php_var_serialize(&sstr, &z, &ht TSRMLS_CC);
*val = sstr.c; *val = sstr.c;
*val_len = (int)sstr.len; *val_len = (int)sstr.len;
#if ZEND_MODULE_API_NO >= 20100000
#else
zend_hash_destroy(&ht); zend_hash_destroy(&ht);
#endif


return 1; return 1;


Expand Down Expand Up @@ -1166,8 +1176,7 @@ redis_unserialize(RedisSock *redis_sock, const char *val, int val_len, zval **re
if(!*return_value) { if(!*return_value) {
MAKE_STD_ZVAL(*return_value); MAKE_STD_ZVAL(*return_value);
} }
var_hash.first = 0; memset(&var_hash, 0, sizeof(var_hash));
var_hash.first_dtor = 0;
if(!php_var_unserialize(return_value, (const unsigned char**)&val, if(!php_var_unserialize(return_value, (const unsigned char**)&val,
(const unsigned char*)val + val_len, &var_hash TSRMLS_CC)) { (const unsigned char*)val + val_len, &var_hash TSRMLS_CC)) {
efree(*return_value); efree(*return_value);
Expand Down

0 comments on commit 04d6237

Please sign in to comment.