if (input_type == IS_UNICODE) {
/* For Unicode, num_pad_chars/pad_length is number of codepoints */
i = 0; input_codepts = 0;
- while (i < input_len) {
- U16_FWD_1((UChar *)input, i, input_len);
- input_codepts++;
- }
+ input_codepts = u_countChar32((UChar *)input, input_len);
num_pad_chars = pad_length - input_codepts;
} else {
num_pad_chars = pad_length - input_len;
}
if (input_type == IS_UNICODE) {
- result = emalloc(UBYTES(input_len + num_pad_chars*2 + 1));
+ result = eumalloc(input_len + num_pad_chars*2 + 1);
} else {
result = emalloc(input_len + num_pad_chars + 1);
}
result_len += zend_codepoint_to_uchar(ch, (UChar *)result + result_len);
}
*((UChar *)result + result_len) = 0;
- result = erealloc(result, UBYTES(result_len+1));
+ result = eurealloc(result, result_len+1);
} else {
for (i = 0; i < left_pad; i++)
*((char *)result + result_len++) = *((char *)padstr + (i % padstr_len));