47 constexpr
size_t NUM_ALLOCATION_RETRIES = 5;
56 for (
size_t t = 0; t < NUM_ALLOCATION_RETRIES ; ++t)
60 auto small_buffer = std::make_shared<std::vector<uint8_t>>();
65 catch(
const std::exception &e)
68 CRL_DEBUG(
"Failed to allocate small buffer. Retrying\n");
75 for (
size_t t = 0; t < NUM_ALLOCATION_RETRIES ; ++t)
79 auto large_buffer = std::make_shared<std::vector<uint8_t>>();
84 catch(
const std::exception &e)
87 CRL_DEBUG(
"Failed to allocate large buffer\n");
103 [](
const auto &small_buffer)
105 return small_buffer.use_count() == 1;
110 (*small_buffer)->resize(target_size, 0);
111 return *small_buffer;
117 [](
const auto &large_buffer)
119 return large_buffer.use_count() == 1;
124 (*large_buffer)->resize(target_size, 0);
125 return *large_buffer;