◆ return_temporary_buffer()

template<typename DerivedPolicy , typename Pointer >
__host__ __device__ void thrust::return_temporary_buffer ( const thrust::detail::execution_policy_base< DerivedPolicy > &  system,
Pointer  p 

return_temporary_buffer deallocates storage associated with a given Thrust system previously allocated by get_temporary_buffer.

Thrust uses return_temporary_buffer internally when deallocating temporary storage required by algorithm implementations.

systemThe Thrust system with which the storage is associated.
pA pointer previously returned by thrust::get_temporary_buffer. If ptr is null, return_temporary_buffer does nothing.
Template Parameters
DerivedPolicyThe name of the derived execution policy.
p shall have been previously allocated by thrust::get_temporary_buffer.

The following code snippet demonstrates how to use return_temporary_buffer to deallocate a range of memory previously allocated by get_temporary_buffer.

#include <thrust/memory.h>
// allocate storage for 100 ints with thrust::get_temporary_buffer
const int N = 100;
typedef thrust::pair<
> ptr_and_size_t;
thrust::device_system_tag device_sys;
ptr_and_size_t ptr_and_size = thrust::get_temporary_buffer<int>(device_sys, N);
// manipulate up to 100 ints
for(int i = 0; i < ptr_and_size.second; ++i)
*ptr_and_size.first = i;
// deallocate storage with thrust::return_temporary_buffer
thrust::return_temporary_buffer(device_sys, ptr_and_size.first);
See also