Skip to content

Latest commit

 

History

History
100 lines (63 loc) · 2.43 KB

freelist-class.md

File metadata and controls

100 lines (63 loc) · 2.43 KB
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: freelist Class
freelist Class
11/04/2016
allocators/stdext::freelist
allocators/stdext::freelist::pop
allocators/stdext::freelist::push
stdext::freelist
stdext::freelist [C++], pop
stdext::freelist [C++], push
8ad7e35c-4c80-4479-8ede-1a2497b06d71

freelist Class

Manages a list of memory blocks.

Syntax

template <std::size_t Sz, class Max>
class freelist : public Max

Parameters

Sz
The number of elements in the array to be allocated.

Max
The max class representing the maximum number of elements to be stored in the free list. The max class can be max_none, max_unbounded, max_fixed_size, or max_variable_size.

Remarks

This class template manages a list of memory blocks of size Sz with the maximum length of the list determined by the max class passed in Max.

Constructors

Constructor Description
freelist Constructs an object of type freelist.

Member functions

Member function Description
pop Removes the first memory block from the free list.
push Adds a memory block to the list.

Requirements

Header: <allocators>

Namespace: stdext

freelist::freelist

Constructs an object of type freelist.

freelist();

Remarks

freelist::pop

Removes the first memory block from the free list.

void *pop();

Return Value

Returns a pointer to the memory block removed from the list.

Remarks

The member function returns NULL if the list is empty. Otherwise, it removes the first memory block from the list.

freelist::push

Adds a memory block to the list.

bool push(void* ptr);

Parameters

ptr
A pointer to the memory block to be added to the free list.

Return Value

true if the full function of the max class returns false; otherwise, the push function returns false.

Remarks

If the full function of the max class returns false, this member function adds the memory block pointed to by ptr to the head of the list.

See also

<allocators>