| 618 | } |
| 619 | |
| 620 | char * |
| 621 | url_string_get_ref(HdrHeap *heap, URLImpl *url, int *length, unsigned normalization_flags) |
| 622 | { |
| 623 | if (!url) { |
| 624 | return nullptr; |
| 625 | } |
| 626 | |
| 627 | if (url->m_ptr_printed_string && url->m_clean && (normalization_flags == url->m_normalization_flags)) { |
| 628 | if (length) { |
| 629 | *length = url->m_len_printed_string; |
| 630 | } |
| 631 | return const_cast<char *>(url->m_ptr_printed_string); |
| 632 | } else { // either not clean or never printed |
| 633 | int len = url_length_get(url, normalization_flags); |
| 634 | char *buf; |
| 635 | int index = 0; |
| 636 | int offset = 0; |
| 637 | |
| 638 | /* stuff alloc'd here gets gc'd on HdrHeap::destroy() */ |
| 639 | buf = heap->allocate_str(len + 1); |
| 640 | url_print(url, buf, len, &index, &offset, normalization_flags); |
| 641 | buf[len] = '\0'; |
| 642 | |
| 643 | if (length) { |
| 644 | *length = len; |
| 645 | } |
| 646 | url->m_clean = true; // reset since we have url_print()'ed again |
| 647 | url->m_len_printed_string = len; |
| 648 | url->m_ptr_printed_string = buf; |
| 649 | url->m_normalization_flags = normalization_flags; |
| 650 | return buf; |
| 651 | } |
| 652 | } |
| 653 | |
| 654 | char * |
| 655 | url_string_get(URLImpl *url, Arena *arena, int *length, HdrHeap *heap) |
no test coverage detected