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

« back to all changes in this revision

Viewing changes to redis_commands.c

  • Committer: GitHub
  • Author(s): Pavlo Yatsukhnenko
  • Date: 2016-09-21 06:18:15 UTC
  • mfrom: (536.1.1)
  • Revision ID: git-v1:1fa240478ff5c1be4dd769c759859b7f66db3526
Merge pull request #953 from yatsukhnenko/develop

Show diffs side-by-side

added added

removed removed

Lines of Context:
564
564
               *withscores = (Z_TYPE_P(z_ele) == IS_BOOL && Z_BVAL_P(z_ele) == 1);
565
565
           } else if (IS_LIMIT_ARG(optkey, optlen) && Z_TYPE_P(z_ele) == IS_ARRAY) {
566
566
                HashTable *htlimit = Z_ARRVAL_P(z_ele);
567
 
                zval **zoff, **zcnt;
 
567
                zval *zoff, *zcnt;
568
568
 
569
569
                /* We need two arguments (offset and count) */
570
 
                if (zend_hash_index_find(htlimit,0,(void**)&zoff)==SUCCESS &&
571
 
                    zend_hash_index_find(htlimit,1,(void**)&zcnt)==SUCCESS)
572
 
                {
 
570
                if ((zoff = zend_hash_index_find(htlimit, 0)) != NULL &&
 
571
                    (zcnt = zend_hash_index_find(htlimit, 1)) != NULL
 
572
                ) {
573
573
                    /* Set our limit if we can get valid longs from both args */
574
 
                    has_limit = zval_get_long(*zoff, &offset) == SUCCESS &&
575
 
                                zval_get_long(*zcnt, &count) == SUCCESS;
 
574
                    has_limit = zval_get_long(zoff, &offset) == SUCCESS &&
 
575
                                zval_get_long(zcnt, &count) == SUCCESS;
576
576
 
577
577
                    /* Inform the user there is a problem if we don't have a limit */
578
578
                    if (!has_limit) {
992
992
 
993
993
    // Make sure we at least have a key, and we can get other args
994
994
    z_args = emalloc(argc * sizeof(zval));
995
 
    if(zend_get_parameters_array(ht, argc, z_args)==FAILURE) {
 
995
    if (zend_get_parameters_array(ht, argc, z_args) == FAILURE) {
996
996
        efree(z_args);
997
997
        return FAILURE;
998
998
    }
1096
1096
 
1097
1097
    // Allocate args
1098
1098
    z_args = emalloc(argc * sizeof(zval));
1099
 
    if(zend_get_parameters_array(ht, argc, z_args)==FAILURE) {
 
1099
    if (zend_get_parameters_array(ht, argc, z_args) == FAILURE) {
1100
1100
        efree(z_args);
1101
1101
        return FAILURE;
1102
1102
    }
1714
1714
 
1715
1715
    // Allocate space for args, parse them as an array
1716
1716
    z_args = emalloc(argc * sizeof(zval));
1717
 
    if(zend_get_parameters_array(ht, argc, z_args)==FAILURE ||
 
1717
    if (zend_get_parameters_array(ht, argc, z_args) == FAILURE ||
1718
1718
       argc < 3 || Z_TYPE(z_args[0]) != IS_STRING)
1719
1719
    {
1720
1720
        efree(z_args);
2513
2513
        ) && Z_TYPE_P(z_ele) == IS_ARRAY
2514
2514
    ) {
2515
2515
        HashTable *ht_off = Z_ARRVAL_P(z_ele);
2516
 
        zval **z_off, **z_cnt;
 
2516
        zval *z_off, *z_cnt;
2517
2517
 
2518
 
        if(zend_hash_index_find(ht_off, 0, (void**)&z_off)==SUCCESS &&
2519
 
           zend_hash_index_find(ht_off, 1, (void**)&z_cnt)==SUCCESS)
2520
 
        {
2521
 
            if((Z_TYPE_PP(z_off)!=IS_STRING && Z_TYPE_PP(z_off)!=IS_LONG) ||
2522
 
               (Z_TYPE_PP(z_cnt)!=IS_STRING && Z_TYPE_PP(z_cnt)!=IS_LONG))
2523
 
            {
 
2518
        if ((z_off = zend_hash_index_find(ht_off, 0)) != NULL &&
 
2519
            (z_cnt = zend_hash_index_find(ht_off, 1)) != NULL
 
2520
        ) {
 
2521
            if ((Z_TYPE_P(z_off) != IS_STRING && Z_TYPE_P(z_off) != IS_LONG) ||
 
2522
                (Z_TYPE_P(z_cnt) != IS_STRING && Z_TYPE_P(z_cnt) != IS_LONG)
 
2523
            ) {
2524
2524
                php_error_docref(NULL TSRMLS_CC, E_WARNING,
2525
2525
                    "LIMIT options on SORT command must be longs or strings");
2526
2526
                if(key_free) efree(key);
2533
2533
            add_next_index_stringl(z_argv,"LIMIT",sizeof("LIMIT")-1,1);
2534
2534
 
2535
2535
            long low, high;
2536
 
            if(Z_TYPE_PP(z_off)==IS_STRING) {
2537
 
                low = atol(Z_STRVAL_PP(z_off));
 
2536
            if (Z_TYPE_P(z_off) == IS_STRING) {
 
2537
                low = atol(Z_STRVAL_P(z_off));
2538
2538
            } else {
2539
 
                low = Z_LVAL_PP(z_off);
 
2539
                low = Z_LVAL_P(z_off);
2540
2540
            }
2541
 
            if(Z_TYPE_PP(z_cnt)==IS_STRING) {
2542
 
                high = atol(Z_STRVAL_PP(z_cnt));
 
2541
            if (Z_TYPE_P(z_cnt) == IS_STRING) {
 
2542
                high = atol(Z_STRVAL_P(z_cnt));
2543
2543
            } else {
2544
 
                high = Z_LVAL_PP(z_cnt);
 
2544
                high = Z_LVAL_P(z_cnt);
2545
2545
            }
2546
2546
 
2547
2547
            // Add our two LIMIT arguments
2599
2599
 
2600
2600
    // Grab arguments as an array
2601
2601
    z_args = emalloc(argc * sizeof(zval));
2602
 
    if(zend_get_parameters_array(ht, argc, z_args)==FAILURE) {
 
2602
    if (zend_get_parameters_array(ht, argc, z_args) == FAILURE) {
2603
2603
        efree(z_args);
2604
2604
        return FAILURE;
2605
2605
    }
2649
2649
    smart_string cmdstr = {0};
2650
2650
 
2651
2651
    z_args = emalloc(argc * sizeof(zval));
2652
 
    if(zend_get_parameters_array(ht, argc, z_args)==FAILURE) {
 
2652
    if (zend_get_parameters_array(ht, argc, z_args) == FAILURE) {
2653
2653
        efree(z_args);
2654
2654
        return FAILURE;
2655
2655
    }