Helper function to convert std::string to zlib_component_string_t
| 132 | |
| 133 | // Helper function to convert std::string to zlib_component_string_t |
| 134 | static void strToComponentString(const std::string &Str, |
| 135 | zlib_component_string_t *CompStr) { |
| 136 | if (Str.empty()) { |
| 137 | CompStr->ptr = nullptr; |
| 138 | CompStr->len = 0; |
| 139 | return; |
| 140 | } |
| 141 | CompStr->ptr = static_cast<uint8_t *>( |
| 142 | canonical_abi_realloc(nullptr, 0, 1, Str.length())); |
| 143 | if (CompStr->ptr) { |
| 144 | memcpy(CompStr->ptr, Str.data(), Str.length()); |
| 145 | CompStr->len = Str.length(); |
| 146 | } else { |
| 147 | CompStr->len = 0; // Allocation failed |
| 148 | fprintf( |
| 149 | stderr, |
| 150 | "ABI Layer Error: Memory allocation failed for string conversion.\n"); |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | bool exports_example_zlib_compressor_deflate(zlib_component_list_u8_t *input, |
| 155 | zlib_component_list_u8_t *ret_ok, |
no test coverage detected