|
29 | 29 | */ |
30 | 30 | constexpr const uint32_t source_size = 2048U; |
31 | 31 |
|
32 | | -// Deallocate dictionary |
33 | | -uint8_t destroy_dictionary(qpl_dictionary** dictionary_ptr) { |
34 | | - if (*dictionary_ptr != nullptr) { |
35 | | - free(*dictionary_ptr); //NOLINT(cppcoreguidelines-no-malloc) |
36 | | - *dictionary_ptr = nullptr; |
37 | | - } |
38 | | - return 0; |
39 | | -} |
40 | | - |
41 | 32 | // Create dictionary with defined path |
42 | 33 | uint8_t create_dictionary(qpl_path_t execution_path, std::vector<uint8_t>& source, qpl_dictionary** dictionary_ptr) { |
43 | 34 | std::size_t dictionary_buffer_size = 0; |
@@ -77,7 +68,11 @@ uint8_t create_dictionary(qpl_path_t execution_path, std::vector<uint8_t>& sourc |
77 | 68 | qpl_build_dictionary(*dictionary_ptr, sw_compr_level, hw_compr_level, raw_dict_ptr, raw_dict_size); |
78 | 69 | if (status != QPL_STS_OK) { |
79 | 70 | std::cout << "An error " << status << " occurred during dictionary building.\n"; |
80 | | - destroy_dictionary(dictionary_ptr); // Clean up allocated memory |
| 71 | + |
| 72 | + // Clean up allocated memory |
| 73 | + free(*dictionary_ptr); //NOLINT(cppcoreguidelines-no-malloc) |
| 74 | + *dictionary_ptr = nullptr; |
| 75 | + |
81 | 76 | return 1; |
82 | 77 | } |
83 | 78 |
|
@@ -240,24 +235,24 @@ auto main(int argc, char** argv) -> int { |
240 | 235 | const uint8_t comp_status = compression(execution_path, source, destination, dictionary_ptr); |
241 | 236 | if (comp_status == QPL_STS_NOT_SUPPORTED_MODE_ERR) { |
242 | 237 | // Free dictionary |
243 | | - destroy_dictionary(&dictionary_ptr); |
| 238 | + free(dictionary_ptr); //NOLINT(cppcoreguidelines-no-malloc) |
244 | 239 | return 0; |
245 | 240 | } else if (comp_status != 0) { |
246 | 241 | // Free dictionary |
247 | | - destroy_dictionary(&dictionary_ptr); |
| 242 | + free(dictionary_ptr); //NOLINT(cppcoreguidelines-no-malloc) |
248 | 243 | return comp_status; |
249 | 244 | } |
250 | 245 |
|
251 | 246 | // Decompression with software_path and check if decompression failed |
252 | 247 | const uint8_t decomp_status = sw_decompression(destination, reference, dictionary_ptr); |
253 | 248 | if (decomp_status != 0) { |
254 | 249 | // Free dictionary |
255 | | - destroy_dictionary(&dictionary_ptr); |
| 250 | + free(dictionary_ptr); //NOLINT(cppcoreguidelines-no-malloc) |
256 | 251 | return decomp_status; |
257 | 252 | } |
258 | 253 |
|
259 | 254 | // Free dictionary |
260 | | - destroy_dictionary(&dictionary_ptr); |
| 255 | + free(dictionary_ptr); //NOLINT(cppcoreguidelines-no-malloc) |
261 | 256 |
|
262 | 257 | // Compare source and reference |
263 | 258 | for (size_t i = 0; i < source.size(); i++) { |
|
0 commit comments