Skip to content

Commit 8aa386d

Browse files
author
Jason Young
committed
Change s to S and using zend_string now
1 parent d60da3a commit 8aa386d

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

rapidjson.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,34 +121,32 @@ int inline rapidjson_parse(zval *self, char *json) /* {{{ */ {
121121

122122
PHP_METHOD(rapidjson, __construct) /* {{{ */ {
123123

124-
uint len = 0;
125-
char *json = NULL;
126-
zval *self = NULL;
124+
zend_string *json = NULL;
125+
zval *self = NULL;
127126

128-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &json, &len) == FAILURE) {
127+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|S", &json) == FAILURE) {
129128
return;
130129
}
131130

132131
self = getThis();
133132

134-
if (len > 0) {
135-
rapidjson_parse(self, json);
133+
if (json != NULL && json->len > 0) {
134+
rapidjson_parse(self, json->val);
136135
}
137136
}
138137
/** }}} */
139138

140139
PHP_METHOD(rapidjson, parse) /* {{{ */ {
141140

142-
uint len = 0;
143-
char *json = NULL;
144-
zval *self = NULL;
141+
zend_string *json = NULL;
142+
zval *self = NULL;
145143

146-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &json, &len) == FAILURE) {
144+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &json) == FAILURE) {
147145
return;
148146
}
149147
self = getThis();
150148

151-
rapidjson_parse(self, json);
149+
rapidjson_parse(self, json->val);
152150
}
153151
/** }}} */
154152

rapidjson.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
$times = 1000;
66
var_dump($json);
77
//$r = new Rapidjson();
8-
$r = new Rapidjson($json);
9-
//$r->parse($json);
8+
$json = '{"a":"b"}';
9+
$r = new Rapidjson();
10+
$r->parse($json);
1011
var_dump($r['name']);
1112
var_dump($r['city']);
1213
exit;

0 commit comments

Comments
 (0)