Skip to content

Commit b9a1c75

Browse files
committed
Converted many functions to the new protocol.
1 parent 576dd06 commit b9a1c75

File tree

5 files changed

+692
-301
lines changed

5 files changed

+692
-301
lines changed

library.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,30 @@ void add_constant_long(zend_class_entry *ce, char *name, int value) {
9797
(void*)&constval, sizeof(zval*), NULL);
9898
}
9999

100+
int
101+
integer_length(int i) {
102+
int sz = 0;
103+
int ci = abs(i);
104+
while (ci>0) {
105+
ci = (ci/10);
106+
sz += 1;
107+
}
108+
if(i == 0) { /* log 0 doesn't make sense. */
109+
sz = 1;
110+
} else if(i < 0) { /* allow for neg sign as well. */
111+
sz++;
112+
}
113+
return sz;
114+
}
115+
116+
int
117+
double_length(double d) {
118+
char *s;
119+
int ret = spprintf(&s, 0, "%f", d);
120+
efree(s);
121+
return ret;
122+
}
123+
100124
/**
101125
* This command behave somehow like printf, except that strings need 2 arguments:
102126
* Their data and their size (strlen).

library.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
void add_constant_long(zend_class_entry *ce, char *name, int value);
2+
int integer_length(int i);
3+
int double_length(double d);
24
int redis_cmd_format(char **ret, char *format, ...);
35

46
PHPAPI char * redis_sock_read(RedisSock *redis_sock, int *buf_len TSRMLS_DC);

php_redis.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ PHP_METHOD(Redis, getSet);
3232
PHP_METHOD(Redis, randomKey);
3333
PHP_METHOD(Redis, renameKey);
3434
PHP_METHOD(Redis, renameNx);
35-
PHP_METHOD(Redis, add);
3635
PHP_METHOD(Redis, getMultiple);
3736
PHP_METHOD(Redis, exists);
3837
PHP_METHOD(Redis, delete);

0 commit comments

Comments
 (0)