MCPcopy Create free account
hub / github.com/cameron314/concurrentqueue / set_max_size

Method set_max_size

benchmarks/dlib/array/array_kernel.h:420–452  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

418 typename mem_manager
419 >
420 void array<T,mem_manager>::
421 set_max_size(
422 size_t max
423 )
424 {
425 reset();
426 array_size = 0;
427 last_pos = 0;
428 if (max != 0)
429 {
430 // if new max size is different
431 if (max != max_array_size)
432 {
433 if (array_elements)
434 {
435 pool.deallocate_array(array_elements);
436 }
437 // try to get more memroy
438 try { array_elements = pool.allocate_array(max); }
439 catch (...) { array_elements = 0; max_array_size = 0; throw; }
440 max_array_size = max;
441 }
442
443 }
444 // if the array is being made to be zero
445 else
446 {
447 if (array_elements)
448 pool.deallocate_array(array_elements);
449 max_array_size = 0;
450 array_elements = 0;
451 }
452 }
453
454// ----------------------------------------------------------------------------------------
455

Callers

nothing calls this directly

Calls 2

deallocate_arrayMethod · 0.45
allocate_arrayMethod · 0.45

Tested by

no test coverage detected