Helper function to convert std::vector to zlib_component_list_u8_t
| 112 | |
| 113 | // Helper function to convert std::vector<uint8_t> to zlib_component_list_u8_t |
| 114 | static void vecToListU8(const std::vector<uint8_t> &Vec, |
| 115 | zlib_component_list_u8_t *List) { |
| 116 | if (Vec.empty()) { |
| 117 | List->ptr = nullptr; |
| 118 | List->len = 0; |
| 119 | return; |
| 120 | } |
| 121 | List->ptr = |
| 122 | static_cast<uint8_t *>(canonical_abi_realloc(nullptr, 0, 1, Vec.size())); |
| 123 | if (List->ptr) { |
| 124 | memcpy(List->ptr, Vec.data(), Vec.size()); |
| 125 | List->len = Vec.size(); |
| 126 | } else { |
| 127 | List->len = 0; // Allocation failed |
| 128 | fprintf(stderr, "ABI Layer Error: Memory allocation failed for list_u8_t " |
| 129 | "conversion.\n"); |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | // Helper function to convert std::string to zlib_component_string_t |
| 134 | static void strToComponentString(const std::string &Str, |
no test coverage detected