From 978fbcf6fc355fcd344feb76ab4b7d6b77e9f7c1 Mon Sep 17 00:00:00 2001 From: vostok4 Date: Fri, 18 Oct 2013 14:37:06 +0200 Subject: Further fixes for building on VC9 Win32, C89 compliance Include win32/php_stdint.h on Win32 (fixes compilation on VC9) Change C++ comments to C89 style (to adhere to PHP project) --- library.c | 188 ++++++++++++++++++++++++++--------------------------- library.h | 2 +- redis_array.c | 24 +++---- redis_array.h | 7 +- redis_array_impl.c | 28 ++++---- redis_array_impl.h | 5 ++ 6 files changed, 132 insertions(+), 122 deletions(-) diff --git a/library.c b/library.c index 7db595b8..4fd523de 100644 --- a/library.c +++ b/library.c @@ -67,9 +67,9 @@ PHP_REDIS_API int redis_check_eof(RedisSock *redis_sock TSRMLS_DC) redis_sock->mode = ATOMIC; redis_sock->watching = 0; } - // Wait for a while before trying to reconnect + /* Wait for a while before trying to reconnect */ if (redis_sock->retry_interval) { - // Random factor to avoid having several (or many) concurrent connections trying to reconnect at the same time + /* Random factor to avoid having several (or many) concurrent connections trying to reconnect at the same time */ long retry_interval = (count ? redis_sock->retry_interval : (random() % redis_sock->retry_interval)); usleep(retry_interval); } @@ -79,7 +79,7 @@ PHP_REDIS_API int redis_check_eof(RedisSock *redis_sock TSRMLS_DC) } } - // Reselect the DB. + /* Reselect the DB. */ if (count && redis_sock->dbNumber) { char *cmd, *response; int cmd_len, response_len; @@ -157,7 +157,7 @@ PHP_REDIS_API char *redis_sock_read_bulk_reply(RedisSock *redis_sock, int bytes } else { char c; int i; - + reply = emalloc(bytes+1); while(offset < bytes) { @@ -225,7 +225,7 @@ PHP_REDIS_API char *redis_sock_read(RedisSock *redis_sock, int *buf_len TSRMLS_D case '+': case ':': - // Single Line Reply + /* Single Line Reply */ /* :123\r\n */ *buf_len = strlen(inbuf) - 2; if(*buf_len >= 2) { @@ -274,10 +274,10 @@ integer_length(int i) { int redis_cmd_format_header(char **ret, char *keyword, int arg_count) { - // Our return buffer + /* Our return buffer */ smart_str buf = {0}; - // Keyword length + /* Keyword length */ int l = strlen(keyword); smart_str_appendc(&buf, '*'); @@ -289,10 +289,10 @@ redis_cmd_format_header(char **ret, char *keyword, int arg_count) { smart_str_appendl(&buf, keyword, l); smart_str_appendl(&buf, _NL, sizeof(_NL) - 1); - // Set our return pointer + /* Set our return pointer */ *ret = buf.c; - // Return the length + /* Return the length */ return buf.len; } @@ -439,26 +439,26 @@ redis_cmd_format(char **ret, char *format, ...) { * Append a command sequence to a Redis command */ int redis_cmd_append_str(char **cmd, int cmd_len, char *append, int append_len) { - // Smart string buffer + /* Smart string buffer */ smart_str buf = {0}; - // Append the current command to our smart_str + /* Append the current command to our smart_str */ smart_str_appendl(&buf, *cmd, cmd_len); - // Append our new command sequence + /* Append our new command sequence */ smart_str_appendc(&buf, '$'); smart_str_append_long(&buf, append_len); smart_str_appendl(&buf, _NL, sizeof(_NL) -1); smart_str_appendl(&buf, append, append_len); smart_str_appendl(&buf, _NL, sizeof(_NL) -1); - // Free our old command + /* Free our old command */ efree(*cmd); - // Set our return pointer + /* Set our return pointer */ *cmd = buf.c; - // Return new command length + /* Return new command length */ return buf.len; } @@ -488,7 +488,7 @@ int redis_cmd_append_sstr(smart_str *str, char *append, int append_len) { smart_str_appendl(str, append, append_len); smart_str_appendl(str, _NL, sizeof(_NL) - 1); - // Return our new length + /* Return our new length */ return str->len; } @@ -519,16 +519,16 @@ int redis_cmd_append_sstr_dbl(smart_str *str, double value) { char dbl_decsep; int retval; - /// Convert to double + /* Convert to double */ REDIS_DOUBLE_TO_STRING(dbl_str, dbl_len, value); - // Append the string + /* Append the string */ retval = redis_cmd_append_sstr(str, dbl_str, dbl_len); - // Free our double string + /* Free our double string */ efree(dbl_str); - // Return new length + /* Return new length */ return retval; } @@ -538,10 +538,10 @@ int redis_cmd_append_sstr_dbl(smart_str *str, double value) { int redis_cmd_append_int(char **cmd, int cmd_len, int append) { char int_buf[32]; - // Conver to an int, capture length + /* Conver to an int, capture length */ int int_len = snprintf(int_buf, sizeof(int_buf), "%d", append); - // Return the new length + /* Return the new length */ return redis_cmd_append_str(cmd, cmd_len, int_buf, int_len); } @@ -688,28 +688,28 @@ PHP_REDIS_API void redis_client_list_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSo int resp_len; zval *z_result, *z_sub_result; - // Pointers for parsing + /* Pointers for parsing */ char *p = resp, *lpos = resp, *kpos = NULL, *vpos = NULL, *p2, *key, *value; - // Key length, done flag + /* Key length, done flag */ int klen, done = 0, is_numeric; - // Make sure we can read a response from Redis + /* Make sure we can read a response from Redis */ if((resp = redis_sock_read(redis_sock, &resp_len TSRMLS_CC)) == NULL) { RETURN_FALSE; } - // Allocate memory for our response + /* Allocate memory for our response */ MAKE_STD_ZVAL(z_result); array_init(z_result); - // Allocate memory for one user (there should be at least one, namely us!) + /* Allocate memory for one user (there should be at least one, namely us!) */ ALLOC_INIT_ZVAL(z_sub_result); array_init(z_sub_result); - // While we've got more to parse + /* While we've got more to parse */ while(!done) { - // What character are we on + /* What character are we on */ switch(*p) { /* We're done */ case '\0': @@ -718,23 +718,23 @@ PHP_REDIS_API void redis_client_list_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSo /* \n, ' ' mean we can pull a k/v pair */ case '\n': case ' ': - // Grab our value + /* Grab our value */ vpos = lpos; - // There is some communication error or Redis bug if we don't - // have a key and value, but check anyway. + /* There is some communication error or Redis bug if we don't + have a key and value, but check anyway. */ if(kpos && vpos) { - // Allocate, copy in our key + /* Allocate, copy in our key */ key = emalloc(klen + 1); strncpy(key, kpos, klen); key[klen] = 0; - // Allocate, copy in our value + /* Allocate, copy in our value */ value = emalloc(p-lpos+1); strncpy(value,lpos,p-lpos+1); value[p-lpos]=0; - // Treat numbers as numbers, strings as strings + /* Treat numbers as numbers, strings as strings */ is_numeric = 1; for(p2 = value; *p; ++p) { if(*p < '0' || *p > '9') { @@ -743,7 +743,7 @@ PHP_REDIS_API void redis_client_list_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSo } } - // Add as a long or string, depending + /* Add as a long or string, depending */ if(is_numeric == 1) { add_assoc_long(z_sub_result, key, atol(value)); efree(value); @@ -751,50 +751,50 @@ PHP_REDIS_API void redis_client_list_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSo add_assoc_string(z_sub_result, key, value, 0); } - // If we hit a '\n', then we can add this user to our list + /* If we hit a '\n', then we can add this user to our list */ if(*p == '\n') { - // Add our user + /* Add our user */ add_next_index_zval(z_result, z_sub_result); - // If we have another user, make another one + /* If we have another user, make another one */ if(*(p+1) != '\0') { ALLOC_INIT_ZVAL(z_sub_result); array_init(z_sub_result); } } - - // Free our key + + /* Free our key */ efree(key); } else { - // Something is wrong + /* Something is wrong */ efree(resp); RETURN_FALSE; } - // Move forward + /* Move forward */ lpos = p + 1; break; /* We can pull the key and null terminate at our sep */ case '=': - // Key, key length + /* Key, key length */ kpos = lpos; klen = p - lpos; - // Move forward + /* Move forward */ lpos = p + 1; break; } - // Increment + /* Increment */ p++; } - // Free our respoonse + /* Free our respoonse */ efree(resp); - IF_MULTI_OR_PIPELINE() { + IF_MULTI_OR_PIPELINE() { add_next_index_zval(z_tab, z_result); } else { RETVAL_ZVAL(z_result, 0, 1); @@ -1236,7 +1236,7 @@ PHP_REDIS_API void redis_send_discard(INTERNAL_FUNCTION_PARAMETERS, RedisSock *r * redis_sock_set_err */ PHP_REDIS_API int redis_sock_set_err(RedisSock *redis_sock, const char *msg, int msg_len) { - // Allocate/Reallocate our last error member + /* Allocate/Reallocate our last error member */ if(msg != NULL && msg_len > 0) { if(redis_sock->err == NULL) { redis_sock->err = emalloc(msg_len + 1); @@ -1244,22 +1244,22 @@ PHP_REDIS_API int redis_sock_set_err(RedisSock *redis_sock, const char *msg, int redis_sock->err = erealloc(redis_sock->err, msg_len +1); } - // Copy in our new error message, set new length, and null terminate + /* Copy in our new error message, set new length, and null terminate */ memcpy(redis_sock->err, msg, msg_len); redis_sock->err[msg_len] = '\0'; redis_sock->err_len = msg_len; } else { - // Free our last error + /* Free our last error */ if(redis_sock->err != NULL) { efree(redis_sock->err); } - // Set to null, with zero length + /* Set to null, with zero length */ redis_sock->err = NULL; redis_sock->err_len = 0; } - // Success + /* Success */ return 0; } @@ -1306,7 +1306,7 @@ PHP_REDIS_API int redis_sock_read_multibulk_reply(INTERNAL_FUNCTION_PARAMETERS, *return_value = *z_multi_result; efree(z_multi_result); } - //zval_copy_ctor(return_value); + /*zval_copy_ctor(return_value); */ return 0; } @@ -1353,7 +1353,7 @@ PHP_REDIS_API int redis_sock_read_multibulk_reply_raw(INTERNAL_FUNCTION_PARAMETE *return_value = *z_multi_result; efree(z_multi_result); } - //zval_copy_ctor(return_value); + /*zval_copy_ctor(return_value); */ return 0; } @@ -1620,7 +1620,7 @@ PHP_REDIS_API int redis_key_prefix(RedisSock *redis_sock, char **key, int *key_len TSRMLS_DC) { int ret_len; char *ret; - + if(redis_sock->prefix == NULL || redis_sock->prefix_len == 0) { return 0; } @@ -1641,60 +1641,60 @@ redis_key_prefix(RedisSock *redis_sock, char **key, int *key_len TSRMLS_DC) { PHP_REDIS_API int redis_sock_gets(RedisSock *redis_sock, char *buf, int buf_size, size_t *line_size TSRMLS_DC) { - // Handle EOF + /* Handle EOF */ if(-1 == redis_check_eof(redis_sock TSRMLS_CC)) { return -1; } if(php_stream_get_line(redis_sock->stream, buf, buf_size, line_size) == NULL) { - // Close, put our socket state into error + /* Close, put our socket state into error */ redis_stream_close(redis_sock TSRMLS_CC); redis_sock->stream = NULL; redis_sock->status = REDIS_SOCK_STATUS_FAILED; redis_sock->mode = ATOMIC; redis_sock->watching = 0; - // Throw a read error exception + /* Throw a read error exception */ zend_throw_exception(redis_exception_ce, "read error on connection", 0 TSRMLS_CC); } - // We don't need \r\n + /* We don't need \r\n */ *line_size-=2; buf[*line_size]='\0'; - // Success! + /* Success! */ return 0; } PHP_REDIS_API int redis_read_reply_type(RedisSock *redis_sock, REDIS_REPLY_TYPE *reply_type, int *reply_info TSRMLS_DC) { - // Make sure we haven't lost the connection, even trying to reconnect + /* Make sure we haven't lost the connection, even trying to reconnect */ if(-1 == redis_check_eof(redis_sock TSRMLS_CC)) { - // Failure + /* Failure */ return -1; } - // Attempt to read the reply-type byte + /* Attempt to read the reply-type byte */ if((*reply_type = php_stream_getc(redis_sock->stream)) == EOF) { zend_throw_exception(redis_exception_ce, "socket error on read socket", 0 TSRMLS_CC); } - // If this is a BULK, MULTI BULK, or simply an INTEGER response, we can extract the value or size info here + /* If this is a BULK, MULTI BULK, or simply an INTEGER response, we can extract the value or size info here */ if(*reply_type == TYPE_INT || *reply_type == TYPE_BULK || *reply_type == TYPE_MULTIBULK) { - // Buffer to hold size information + /* Buffer to hold size information */ char inbuf[255]; - // Read up to our newline + /* Read up to our newline */ if(php_stream_gets(redis_sock->stream, inbuf, sizeof(inbuf)) < 0) { return -1; } - // Set our size response + /* Set our size response */ *reply_info = atoi(inbuf); } - // Success! + /* Success! */ return 0; } @@ -1703,28 +1703,28 @@ redis_read_reply_type(RedisSock *redis_sock, REDIS_REPLY_TYPE *reply_type, int * */ PHP_REDIS_API int redis_read_variant_line(RedisSock *redis_sock, REDIS_REPLY_TYPE reply_type, zval **z_ret TSRMLS_DC) { - // Buffer to read our single line reply + /* Buffer to read our single line reply */ char inbuf[1024]; size_t line_size; - // Attempt to read our single line reply + /* Attempt to read our single line reply */ if(redis_sock_gets(redis_sock, inbuf, sizeof(inbuf), &line_size TSRMLS_CC) < 0) { return -1; } - // If this is an error response, check if it is a SYNC error, and throw in that case + /* If this is an error response, check if it is a SYNC error, and throw in that case */ if(reply_type == TYPE_ERR) { if(memcmp(inbuf, "ERR SYNC", 9) == 0) { zend_throw_exception(redis_exception_ce, "SYNC with master in progress", 0 TSRMLS_CC); } - // Set our last error + /* Set our last error */ redis_sock_set_err(redis_sock, inbuf, line_size); - // Set our response to FALSE + /* Set our response to FALSE */ ZVAL_FALSE(*z_ret); } else { - // Set our response to TRUE + /* Set our response to TRUE */ ZVAL_TRUE(*z_ret); } @@ -1733,10 +1733,10 @@ redis_read_variant_line(RedisSock *redis_sock, REDIS_REPLY_TYPE reply_type, zval PHP_REDIS_API int redis_read_variant_bulk(RedisSock *redis_sock, int size, zval **z_ret TSRMLS_DC) { - // Attempt to read the bulk reply + /* Attempt to read the bulk reply */ char *bulk_resp = redis_sock_read_bulk_reply(redis_sock, size TSRMLS_CC); - // Set our reply to FALSE on failure, and the string on success + /* Set our reply to FALSE on failure, and the string on success */ if(bulk_resp == NULL) { ZVAL_FALSE(*z_ret); return -1; @@ -1752,15 +1752,15 @@ redis_read_multibulk_recursive(RedisSock *redis_sock, int elements, zval **z_ret REDIS_REPLY_TYPE reply_type; zval *z_subelem; - // Iterate while we have elements + /* Iterate while we have elements */ while(elements > 0) { - // Attempt to read our reply type + /* Attempt to read our reply type */ if(redis_read_reply_type(redis_sock, &reply_type, &reply_info TSRMLS_CC) < 0) { zend_throw_exception_ex(redis_exception_ce, 0 TSRMLS_CC, "protocol error, couldn't parse MULTI-BULK response\n", reply_type); return -1; } - // Switch on our reply-type byte + /* Switch on our reply-type byte */ switch(reply_type) { case TYPE_ERR: case TYPE_LINE: @@ -1769,17 +1769,17 @@ redis_read_multibulk_recursive(RedisSock *redis_sock, int elements, zval **z_ret add_next_index_zval(*z_ret, z_subelem); break; case TYPE_INT: - // Add our long value + /* Add our long value */ add_next_index_long(*z_ret, reply_info); break; case TYPE_BULK: - // Init a zval for our bulk response, read and add it + /* Init a zval for our bulk response, read and add it */ ALLOC_INIT_ZVAL(z_subelem); redis_read_variant_bulk(redis_sock, reply_info, &z_subelem TSRMLS_CC); add_next_index_zval(*z_ret, z_subelem); break; case TYPE_MULTIBULK: - // Construct an array for our sub element, and add it, and recurse + /* Construct an array for our sub element, and add it, and recurse */ ALLOC_INIT_ZVAL(z_subelem); array_init(z_subelem); add_next_index_zval(*z_ret, z_subelem); @@ -1787,7 +1787,7 @@ redis_read_multibulk_recursive(RedisSock *redis_sock, int elements, zval **z_ret break; } - // Decrement our element counter + /* Decrement our element counter */ elements--; } @@ -1796,21 +1796,21 @@ redis_read_multibulk_recursive(RedisSock *redis_sock, int elements, zval **z_ret PHP_REDIS_API int redis_read_variant_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab) { - // Reply type, and reply size vars + /* Reply type, and reply size vars */ REDIS_REPLY_TYPE reply_type; int reply_info; - //char *bulk_resp; + /*char *bulk_resp; */ zval *z_ret; - // Attempt to read our header + /* Attempt to read our header */ if(redis_read_reply_type(redis_sock, &reply_type, &reply_info TSRMLS_CC) < 0) { return -1; } - // Our return ZVAL + /* Our return ZVAL */ MAKE_STD_ZVAL(z_ret); - // Switch based on our top level reply type + /* Switch based on our top level reply type */ switch(reply_type) { case TYPE_ERR: case TYPE_LINE: @@ -1823,16 +1823,16 @@ redis_read_variant_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zv redis_read_variant_bulk(redis_sock, reply_info, &z_ret TSRMLS_CC); break; case TYPE_MULTIBULK: - // Initialize an array for our multi-bulk response + /* Initialize an array for our multi-bulk response */ array_init(z_ret); - // If we've got more than zero elements, parse our multi bulk respoinse recursively + /* If we've got more than zero elements, parse our multi bulk respoinse recursively */ if(reply_info > -1) { redis_read_multibulk_recursive(redis_sock, reply_info, &z_ret TSRMLS_CC); } break; default: - // Protocol error + /* Protocol error */ zend_throw_exception_ex(redis_exception_ce, 0 TSRMLS_CC, "protocol error, got '%c' as reply-type byte\n", reply_type); break; } @@ -1840,14 +1840,14 @@ redis_read_variant_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zv IF_MULTI_OR_PIPELINE() { add_next_index_zval(z_tab, z_ret); } else { - // Set our return value + /* Set our return value */ *return_value = *z_ret; zval_copy_ctor(return_value); zval_dtor(z_ret); efree(z_ret); } - // Success + /* Success */ return 0; } diff --git a/library.h b/library.h index ec34987c..b749cf63 100644 --- a/library.h +++ b/library.h @@ -38,7 +38,7 @@ PHP_REDIS_API int redis_sock_read_multibulk_reply_assoc(INTERNAL_FUNCTION_PARAME PHP_REDIS_API int redis_sock_write(RedisSock *redis_sock, char *cmd, size_t sz TSRMLS_DC); PHP_REDIS_API void redis_stream_close(RedisSock *redis_sock TSRMLS_DC); PHP_REDIS_API int redis_check_eof(RedisSock *redis_sock TSRMLS_DC); -//PHPAPI int redis_sock_get(zval *id, RedisSock **redis_sock TSRMLS_DC); +/* PHPAPI int redis_sock_get(zval *id, RedisSock **redis_sock TSRMLS_DC); */ PHP_REDIS_API void redis_free_socket(RedisSock *redis_sock); PHP_REDIS_API void redis_send_discard(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock); PHP_REDIS_API int redis_sock_set_err(RedisSock *redis_sock, const char *msg, int msg_len); diff --git a/redis_array.c b/redis_array.c index 12fe9830..60d1022b 100644 --- a/redis_array.c +++ b/redis_array.c @@ -293,7 +293,7 @@ static void ra_forward_call(INTERNAL_FUNCTION_PARAMETERS, RedisArray *ra, const char *cmd, int cmd_len, zval *z_args, zval *z_new_target) { zval **zp_tmp, z_tmp; - char *key = NULL; // set to avoid "unused-but-set-variable" + char *key = NULL; /* set to avoid "unused-but-set-variable" */ int key_len; int i; zval *redis_inst; @@ -607,41 +607,41 @@ PHP_METHOD(RedisArray, keys) char *pattern; int pattern_len, i; - // Make sure the prototype is correct + /* Make sure the prototype is correct */ if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, redis_array_ce, &pattern, &pattern_len) == FAILURE) { RETURN_FALSE; } - // Make sure we can grab our RedisArray object + /* Make sure we can grab our RedisArray object */ if(redis_array_get(object, &ra TSRMLS_CC) < 0) { RETURN_FALSE; } - // Set up our function call (KEYS) + /* Set up our function call (KEYS) */ ZVAL_STRING(&z_fun, "KEYS", 0); - // We will be passing with one string argument (the pattern) + /* We will be passing with one string argument (the pattern) */ MAKE_STD_ZVAL(z_args[0]); ZVAL_STRINGL(z_args[0], pattern, pattern_len, 0); - // Init our array return + /* Init our array return */ array_init(return_value); - // Iterate our RedisArray nodes + /* Iterate our RedisArray nodes */ for(i=0; icount; ++i) { - // Return for this node + /* Return for this node */ MAKE_STD_ZVAL(z_tmp); - // Call KEYS on each node + /* Call KEYS on each node */ call_user_function(&redis_ce->function_table, &ra->redis[i], &z_fun, z_tmp, 1, z_args TSRMLS_CC); - // Add the result for this host + /* Add the result for this host */ add_assoc_zval(return_value, ra->hosts[i], z_tmp); } - // Free arg array + /* Free arg array */ efree(z_args[0]); } @@ -1186,7 +1186,7 @@ PHP_METHOD(RedisArray, del) found++; } - if(!found) { // don't run empty DELs + if(!found) { /* don't run empty DELs */ zval_dtor(z_argarray); efree(z_argarray); continue; diff --git a/redis_array.h b/redis_array.h index 652b5aef..3b1163bf 100644 --- a/redis_array.h +++ b/redis_array.h @@ -1,7 +1,12 @@ #ifndef REDIS_ARRAY_H #define REDIS_ARRAY_H +#ifdef PHP_WIN32 +#include "win32/php_stdint.h" +#else #include +#endif + #include "common.h" void redis_destructor_redis_array(zend_rsrc_list_entry * rsrc TSRMLS_DC); @@ -34,7 +39,7 @@ PHP_METHOD(RedisArray, unwatch); typedef struct RedisArray_ { - + int count; char **hosts; /* array of host:port strings */ zval **redis; /* array of Redis instances */ diff --git a/redis_array_impl.c b/redis_array_impl.c index 65ccd61f..10c7dc81 100644 --- a/redis_array_impl.c +++ b/redis_array_impl.c @@ -348,7 +348,7 @@ ra_call_extractor(RedisArray *ra, const char *key, int key_len, int *out_len TSR php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not call extractor function"); return NULL; } - //convert_to_string(ra->z_fun); + /* convert_to_string(ra->z_fun); */ /* call extraction function */ MAKE_STD_ZVAL(z_argv0); @@ -408,7 +408,7 @@ ra_call_distributor(RedisArray *ra, const char *key, int key_len, int *pos TSRML php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not call distributor function"); return 0; } - //convert_to_string(ra->z_fun); + /* convert_to_string(ra->z_fun); */ /* call extraction function */ MAKE_STD_ZVAL(z_argv0); @@ -448,7 +448,7 @@ ra_find_node(RedisArray *ra, const char *key, int key_len, int *out_pos TSRMLS_D /* hash */ hash = rcrc32(out, out_len); efree(out); - + /* get position on ring */ h64 = hash; h64 *= ra->count; @@ -502,7 +502,7 @@ ra_index_multi(zval *z_redis, long multi_value TSRMLS_DC) { ZVAL_LONG(z_args[0], multi_value); call_user_function(&redis_ce->function_table, &z_redis, &z_fun_multi, &z_ret, 1, z_args TSRMLS_CC); efree(z_args[0]); - //zval_dtor(&z_ret); + /* zval_dtor(&z_ret); */ } static void @@ -630,8 +630,8 @@ ra_index_exec(zval *z_redis, zval *return_value, int keep_all TSRMLS_DC) { zval_dtor(&z_ret); } - //zval *zptr = &z_ret; - //php_var_dump(&zptr, 0 TSRMLS_CC); + /* zval *zptr = &z_ret; */ + /* php_var_dump(&zptr, 0 TSRMLS_CC); */ } void @@ -773,7 +773,7 @@ ra_get_key_type(zval *z_redis, const char *key, int key_len, zval *z_from, long if(zend_hash_get_current_data(retHash, (void**)&z_data) == FAILURE) { success = 0; break; - } + } if(Z_TYPE_PP(z_data) != IS_LONG) { success = 0; break; @@ -865,7 +865,7 @@ ra_move_zset(const char *key, int key_len, zval *z_from, zval *z_to, long ttl TS unsigned int val_len; int i; unsigned long idx; - + /* run ZRANGE key 0 -1 WITHSCORES on source */ ZVAL_STRINGL(&z_fun_zrange, "ZRANGE", 6, 0); for(i = 0; i < 4; ++i) { @@ -917,7 +917,7 @@ ra_move_zset(const char *key, int key_len, zval *z_from, zval *z_to, long ttl TS ZVAL_LONG(z_zadd_args[i+1], (long)idx); break; default: - return -1; // Todo: log error + return -1; /* Todo: log error */ break; } i += 2; @@ -1123,23 +1123,23 @@ ra_move_key(const char *key, int key_len, zval *z_from, zval *z_to TSRMLS_DC) { case REDIS_STRING: success = ra_move_string(key, key_len, z_from, z_to, ttl TSRMLS_CC); break; - + case REDIS_SET: success = ra_move_set(key, key_len, z_from, z_to, ttl TSRMLS_CC); break; - + case REDIS_LIST: success = ra_move_list(key, key_len, z_from, z_to, ttl TSRMLS_CC); break; - + case REDIS_ZSET: success = ra_move_zset(key, key_len, z_from, z_to, ttl TSRMLS_CC); break; - + case REDIS_HASH: success = ra_move_hash(key, key_len, z_from, z_to, ttl TSRMLS_CC); break; - + default: /* TODO: report? */ break; diff --git a/redis_array_impl.h b/redis_array_impl.h index 10f8512a..8f106542 100644 --- a/redis_array_impl.h +++ b/redis_array_impl.h @@ -1,7 +1,12 @@ #ifndef REDIS_ARRAY_IMPL_H #define REDIS_ARRAY_IMPL_H +#ifdef PHP_WIN32 +#include "win32/php_stdint.h" +#else #include +#endif + #include "common.h" #include "redis_array.h" -- cgit v1.2.3