116 #define Check(cond) if (!(cond)) { free(str); return NULL; } else ((void)0)
118 uint8_t highbyte, flagbyte, flagbits,
size, length, i;
119 const uint8_t *in = (uint8_t *)data + strlen(data) + 1;
120 const uint8_t *end_in = (uint8_t *)data + len;
121 char *str = calloc(len + 1, 3);
123 char *end_out = str + len * 3;
127 if (end_in - in <= 1) {
137 while (in < end_in && out < end_out) {
143 switch ((flagbyte >> flagbits) & 3) {
145 Check(in + 1 <= end_in);
150 Check(in + 1 <= end_in);
155 Check(in + 2 <= end_in);
161 Check(in + 1 <= end_in);
163 if ((length & 0x80)) {
164 uint8_t correction = *in++;
165 for (i = 0; i < (length & 0x7F) + 2; i++) {
167 out +=
ar_conv_rune_to_utf8(((uint16_t)highbyte << 8) | (data[size] + (correction & 0xFF)), out, end_out - out);
172 for (i = 0; i < (length & 0x7F) + 2; i++) {