~alexlawn/php-redis/alex-redis-hmget

« back to all changes in this revision

Viewing changes to redis_array.c

  • Committer: GitHub
  • Author(s): Pavlo Yatsukhnenko
  • Date: 2016-09-06 17:49:48 UTC
  • mfrom: (526.2.4)
  • Revision ID: git-v1:8eae7ec092be67cbda5e47d95bd42d5b082116ca
Merge pull request #939 from yatsukhnenko/develop

WIP: php7 compatibility

Show diffs side-by-side

added added

removed removed

Lines of Context:
334
334
        int i;
335
335
        zval *redis_inst;
336
336
        zval z_fun, **z_callargs;
337
 
        HashPosition pointer;
338
337
        HashTable *h_args;
339
338
 
340
339
        int argc;
372
371
        z_callargs = emalloc(argc * sizeof(zval*));
373
372
 
374
373
        /* copy args to array */
375
 
        for (i = 0, zend_hash_internal_pointer_reset_ex(h_args, &pointer);
376
 
                        zend_hash_get_current_data_ex(h_args, (void**) &zp_tmp,
377
 
                                &pointer) == SUCCESS;
378
 
                        ++i, zend_hash_move_forward_ex(h_args, &pointer)) {
379
 
 
 
374
    i = 0;
 
375
    ZEND_HASH_FOREACH_VAL(h_args, zp_tmp) {
380
376
                z_callargs[i] = *zp_tmp;
381
 
        }
 
377
        i++;
 
378
    } ZEND_HASH_FOREACH_END();
382
379
 
383
380
        /* multi/exec */
384
381
        if(ra->z_multi_exec) {
845
842
        RedisArray *ra;
846
843
        int *pos, argc, *argc_each;
847
844
        HashTable *h_keys;
848
 
        HashPosition pointer;
849
845
        zval **redis_instances, **argv;
850
846
 
851
847
        /* Multi/exec support */
875
871
        memset(argc_each, 0, ra->count * sizeof(int));
876
872
 
877
873
        /* associate each key to a redis node */
878
 
        for (i = 0, zend_hash_internal_pointer_reset_ex(h_keys, &pointer);
879
 
                        zend_hash_get_current_data_ex(h_keys, (void**) &data,
880
 
                                &pointer) == SUCCESS;
881
 
                        zend_hash_move_forward_ex(h_keys, &pointer), ++i)
882
 
        {
 
874
    i = 0;
 
875
    ZEND_HASH_FOREACH_VAL(h_keys, data) {
883
876
            /* If we need to represent a long key as a string */
884
877
            unsigned int key_len;
885
878
            char kbuf[40], *key_lookup;
908
901
 
909
902
                argc_each[pos[i]]++;    /* count number of keys per node */
910
903
                argv[i] = *data;
911
 
        }
 
904
        i++;
 
905
        } ZEND_HASH_FOREACH_END();
912
906
 
913
907
        /* prepare return value */
914
908
        array_init(return_value);
1139
1133
        RedisArray *ra;
1140
1134
        int *pos, argc, *argc_each;
1141
1135
        HashTable *h_keys;
1142
 
        HashPosition pointer;
1143
1136
        zval **redis_instances, *redis_inst, **argv;
1144
1137
        long total = 0;
1145
1138
        int free_zkeys = 0;
1193
1186
        memset(argc_each, 0, ra->count * sizeof(int));
1194
1187
 
1195
1188
        /* associate each key to a redis node */
1196
 
        for (i = 0, zend_hash_internal_pointer_reset_ex(h_keys, &pointer);
1197
 
                        zend_hash_get_current_data_ex(h_keys, (void**) &data,
1198
 
                                &pointer) == SUCCESS;
1199
 
                        zend_hash_move_forward_ex(h_keys, &pointer), ++i) {
1200
 
 
 
1189
    i = 0;
 
1190
    ZEND_HASH_FOREACH_VAL(h_keys, data) {
1201
1191
                if (Z_TYPE_PP(data) != IS_STRING) {
1202
1192
                        php_error_docref(NULL TSRMLS_CC, E_ERROR, "DEL: all keys must be string.");
1203
1193
                        efree(pos);
1207
1197
                redis_instances[i] = ra_find_node(ra, Z_STRVAL_PP(data), Z_STRLEN_PP(data), &pos[i] TSRMLS_CC);
1208
1198
                argc_each[pos[i]]++;    /* count number of keys per node */
1209
1199
                argv[i] = *data;
1210
 
        }
 
1200
        i++;
 
1201
        } ZEND_HASH_FOREACH_END();
1211
1202
 
1212
1203
        /* calls */
1213
1204
        for(n = 0; n < ra->count; ++n) { /* for each node */