MCPcopy Create free account
hub / github.com/ElementsProject/elements / setup

Method setup

src/cuckoocache.h:336–349  ·  view source on GitHub ↗

setup initializes the container to store no more than new_size * elements. * * setup should only be called once. * * @param new_size the desired number of elements to store * @returns the maximum number of elements storable */

Source from the content-addressed store, hash-verified

334 * @returns the maximum number of elements storable
335 */
336 uint32_t setup(uint32_t new_size)
337 {
338 // depth_limit must be at least one otherwise errors can occur.
339 depth_limit = static_cast<uint8_t>(std::log2(static_cast<float>(std::max((uint32_t)2, new_size))));
340 size = std::max<uint32_t>(2, new_size);
341 table.resize(size);
342 collection_flags.setup(size);
343 epoch_flags.resize(size);
344 // Set to 45% as described above
345 epoch_size = std::max((uint32_t)1, (45 * size) / 100);
346 // Initially set to wait for a whole epoch
347 epoch_heuristic_counter = epoch_size;
348 return size;
349 }
350
351 /** setup_bytes is a convenience function which accounts for internal memory
352 * usage when deciding how many elements to store. It isn't perfect because

Callers 1

FUZZ_TARGETFunction · 0.45

Calls 1

resizeMethod · 0.45

Tested by 1

FUZZ_TARGETFunction · 0.36