Книга: Standard Template Library Programmer
return_temporary_buffer
Разделы на этой странице:
return_temporary_buffer
Category: allocators
Component type: function
Prototype
template <class T>
void return_temporary_buffer(T* p);
Description
Return_temporary_buffer is used to deallocate memory that was allocated using get_temporary_buffer. [1]
Note: get_temporary_buffer and return_temporary_buffer are only provided for backward compatibility. If you are writing new code, you should instead use the temporary_buffer class.
Definition
Defined in the standard header memory , and in the nonstandard backward-compatibility header algo.h .
Preconditions
The argument p is a pointer to a block of memory that was allocated using get_temporary_buffer(ptrdiff_t, T*).
Example
int main() {
pair<int*, ptrdiff_t> P = get_temporary_buffer(10000, (int*)0);
int* buf = P.first;
ptrdiff_t N = P.second;
uninitialized_fill_n(buf, N, 42);
int* result = find_if(buf, buf + N, bind2nd(not_equal_to<int>(), 42));
assert(result == buf + N);
return_temporary_buffer(buf);
}
Notes
[1] As is always true, memory that was allocated using a particular allocation function must be deallocated using the corresponding deallocation function. Memory obtained using get_temporary_buffer must be deallocated using return_temporary_buffer, rather than using free or ::operator delete.
See also
temporary_buffer, get_temporary_buffer, Allocators
- get_temporary_buffer
- temporary_buffer
- Page buffers
- TCP REMOTE BUFFER
- RETURN target
- DirectX Tutorial 4: Full Screen and Depth Buffers
- Temporary File Storage in the
- Measuring Key Buffer Usage
- 14.5.2. Dumping the printk Log Buffer
- 2.3.5. Buffered versus Unbuffered Primitives
- Function Return Values
- 4.2.1 Switching Buffers