|
60 | 60 | # include "php_mbregex.h"
|
61 | 61 | #endif
|
62 | 62 |
|
| 63 | +#include "zend_smart_str.h" |
63 | 64 | #include "zend_multibyte.h"
|
64 | 65 | #include "mbstring_arginfo.h"
|
65 | 66 |
|
@@ -1281,19 +1282,15 @@ PHP_FUNCTION(mb_http_input)
|
1281 | 1282 | if (n == 0) {
|
1282 | 1283 | RETURN_FALSE;
|
1283 | 1284 | }
|
1284 |
| - // TODO Use smart_str instead. |
1285 |
| - mbfl_string result; |
1286 |
| - mbfl_memory_device device; |
1287 |
| - mbfl_memory_device_init(&device, n * 12, 0); |
| 1285 | + |
| 1286 | + smart_str result = {0}; |
1288 | 1287 | for (size_t i = 0; i < n; i++, entry++) {
|
1289 |
| - mbfl_memory_device_strcat(&device, (*entry)->name); |
1290 |
| - mbfl_memory_device_output(',', &device); |
| 1288 | + if (i > 0) { |
| 1289 | + smart_str_appendc(&result, ','); |
| 1290 | + } |
| 1291 | + smart_str_appends(&result, (*entry)->name); |
1291 | 1292 | }
|
1292 |
| - mbfl_memory_device_unput(&device); /* Remove trailing comma */ |
1293 |
| - mbfl_memory_device_result(&device, &result); |
1294 |
| - RETVAL_STRINGL((const char*)result.val, result.len); |
1295 |
| - mbfl_string_clear(&result); |
1296 |
| - return; |
| 1293 | + RETURN_STR(smart_str_extract(&result)); |
1297 | 1294 | default:
|
1298 | 1295 | zend_argument_value_error(1,
|
1299 | 1296 | "must be one of \"G\", \"P\", \"C\", \"S\", \"I\", or \"L\"");
|
|
0 commit comments