| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 99650e1 commit 4082dd0
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3867,57 +3867,32 @@ int redis_sort_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, | |||
| 3867 | 3867 | int redis_hdel_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, | |
| 3868 | 3868 | char **cmd, int *cmd_len, short *slot, void **ctx) | |
| 3869 | 3869 | { | |
| 3870 | - zval *z_args; | ||
| 3871 | 3870 | smart_string cmdstr = {0}; | |
| 3872 | - char *arg; | ||
| 3873 | - int arg_free, i; | ||
| 3874 | - size_t arg_len; | ||
| 3875 | - int argc = ZEND_NUM_ARGS(); | ||
| 3876 | - zend_string *zstr; | ||
| 3877 | - | ||
| 3878 | - // We need at least KEY and one member | ||
| 3879 | - if (argc < 2) { | ||
| 3880 | - return FAILURE; | ||
| 3881 | - } | ||
| 3882 | - | ||
| 3883 | - // Grab arguments as an array | ||
| 3884 | - z_args = emalloc(argc * sizeof(zval)); | ||
| 3885 | - if (zend_get_parameters_array(ht, argc, z_args) == FAILURE) { | ||
| 3886 | - efree(z_args); | ||
| 3887 | - return FAILURE; | ||
| 3888 | - } | ||
| 3889 | - | ||
| 3890 | - // Get first argument (the key) as a string | ||
| 3891 | - zstr = zval_get_string(&z_args[0]); | ||
| 3892 | - arg = ZSTR_VAL(zstr); | ||
| 3893 | - arg_len = ZSTR_LEN(zstr); | ||
| 3871 | + zend_string *key = NULL; | ||
| 3872 | + int i; | ||
| 3873 | + int argc = 0; | ||
| 3874 | + zval *args; | ||
| 3894 | 3875 | ||
| 3895 | - // Prefix | ||
| 3896 | - arg_free = redis_key_prefix(redis_sock, &arg, &arg_len); | ||
| 3876 | + ZEND_PARSE_PARAMETERS_START(2, -1) | ||
| 3877 | + Z_PARAM_STR(key) | ||
| 3878 | + Z_PARAM_VARIADIC('*', args, argc) | ||
| 3879 | + ZEND_PARSE_PARAMETERS_END_EX(return FAILURE); | ||
| 3897 | 3880 | ||
| 3898 | 3881 | // Start command construction | |
| 3899 | - redis_cmd_init_sstr(&cmdstr, argc, ZEND_STRL("HDEL")); | ||
| 3900 | - redis_cmd_append_sstr(&cmdstr, arg, arg_len); | ||
| 3882 | + redis_cmd_init_sstr(&cmdstr, argc + 1, ZEND_STRL("HDEL")); | ||
| 3901 | 3883 | ||
| 3902 | - // Set our slot, free key if we prefixed it | ||
| 3903 | - CMD_SET_SLOT(slot,arg,arg_len); | ||
| 3904 | - zend_string_release(zstr); | ||
| 3905 | - if (arg_free) efree(arg); | ||
| 3884 | + // Append key | ||
| 3885 | + redis_cmd_append_sstr_key_zstr(&cmdstr, key, redis_sock, slot); | ||
| 3906 | 3886 | ||
| 3907 | 3887 | // Iterate through the members we're removing | |
| 3908 | - for (i = 1; i < argc; i++) { | ||
| 3909 | - zstr = zval_get_string(&z_args[i]); | ||
| 3910 | - redis_cmd_append_sstr(&cmdstr, ZSTR_VAL(zstr), ZSTR_LEN(zstr)); | ||
| 3911 | - zend_string_release(zstr); | ||
| 3888 | + for (i = 0; i < argc; i++) { | ||
| 3889 | + redis_cmd_append_sstr_zval(&cmdstr, &args[i], NULL); | ||
| 3912 | 3890 | } | |
| 3913 | 3891 | ||
| 3914 | 3892 | // Push out values | |
| 3915 | 3893 | *cmd = cmdstr.c; | |
| 3916 | 3894 | *cmd_len = cmdstr.len; | |
| 3917 | 3895 | ||
| 3918 | - // Cleanup | ||
| 3919 | - efree(z_args); | ||
| 3920 | - | ||
| 3921 | 3896 | // Success! | |
| 3922 | 3897 | return SUCCESS; | |
| 3923 | 3898 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments