| 754 | }; |
| 755 | |
| 756 | nfdresult_t CopyFilterItem(const nfdu8filteritem_t* filterList, |
| 757 | nfdfiltersize_t count, |
| 758 | FilterItem_Guard& filterItemsNGuard) { |
| 759 | if (count) { |
| 760 | nfdnfilteritem_t*& filterItemsN = filterItemsNGuard.data; |
| 761 | filterItemsN = NFDi_Malloc<nfdnfilteritem_t>(sizeof(nfdnfilteritem_t) * count); |
| 762 | if (!filterItemsN) { |
| 763 | return NFD_ERROR; |
| 764 | } |
| 765 | |
| 766 | nfdfiltersize_t& index = filterItemsNGuard.index; |
| 767 | for (; index != count; ++index) { |
| 768 | nfdresult_t res = CopyCharToWChar(filterList[index].name, |
| 769 | const_cast<nfdnchar_t*&>(filterItemsN[index].name)); |
| 770 | if (!res) { |
| 771 | return NFD_ERROR; |
| 772 | } |
| 773 | res = CopyCharToWChar(filterList[index].spec, |
| 774 | const_cast<nfdnchar_t*&>(filterItemsN[index].spec)); |
| 775 | if (!res) { |
| 776 | // remember to free the name, because we also created it (and it won't be protected |
| 777 | // by the guard, because we have not incremented the index) |
| 778 | NFDi_Free(const_cast<nfdnchar_t*>(filterItemsN[index].name)); |
| 779 | return NFD_ERROR; |
| 780 | } |
| 781 | } |
| 782 | } |
| 783 | return NFD_OKAY; |
| 784 | } |
| 785 | nfdresult_t ConvertU8ToNative(const nfdu8char_t* u8Text, FreeCheck_Guard<nfdnchar_t>& nativeText) { |
| 786 | if (u8Text) { |
| 787 | nfdresult_t res = CopyCharToWChar(u8Text, nativeText.data); |
no test coverage detected