thrust::malloc
Defined in thrust/memory.h
- 
template<typename T, typename DerivedPolicy>
 pointer<T, DerivedPolicy> thrust::malloc(const thrust::detail::execution_policy_base<DerivedPolicy> &system, std::size_t n)
- This version of - mallocallocates typed uninitialized storage associated with a given system.- The following code snippet demonstrates how to use - mallocto allocate a range of memory to accommodate integers associated with Thrust’s device system.- #include <thrust/memory.h> ... // allocate storage for 100 ints with thrust::malloc const int N = 100; thrust::device_system_tag device_sys; thrust::pointer<int,thrust::device_system_tag> ptr = thrust::malloc<int>(device_sys, N); // manipulate memory ... // deallocate ptr with thrust::free thrust::free(device_sys, ptr); - See also - free - See also - device_malloc - Parameters
- system – The Thrust system with which to associate the storage. 
- n – The number of elements of type - Twhich the storage should accommodate.
 
- Template Parameters
- DerivedPolicy – The name of the derived execution policy. 
- Returns
- If allocation succeeds, a pointer to an allocation large enough to accommodate - nelements of type- T; a null pointer otherwise. The pointer must be deallocated with- thrust::free.
- Pre
- DerivedPolicymust be publicly derived from- thrust::execution_policy<DerivedPolicy>.