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

Function NFS_Allocate

benchmarks/tbb/cache_aligned_allocator.cpp:181–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179#endif
180
181void* NFS_Allocate( size_t n, size_t element_size, void* /*hint*/ ) {
182 size_t m = NFS_LineSize;
183 __TBB_ASSERT( m<=NFS_MaxLineSize, "illegal value for NFS_LineSize" );
184 __TBB_ASSERT( (m & (m-1))==0, "must be power of two" );
185 size_t bytes = n*element_size;
186
187 if (bytes<n || bytes+m<bytes) {
188 // Overflow
189 throw_exception(eid_bad_alloc);
190 }
191 // scalable_aligned_malloc considers zero size request an error, and returns NULL
192 if (bytes==0) bytes = 1;
193
194 void* result = (*padded_allocate_handler)( bytes, m );
195 if (!result)
196 throw_exception(eid_bad_alloc);
197
198 __TBB_ASSERT( ((size_t)result&(m-1)) == 0, "The address returned isn't aligned to cache line size" );
199 return result;
200}
201
202void NFS_Free( void* p ) {
203 (*padded_free_handler)( p );

Callers 12

allocate_schedulerMethod · 0.85
allocate_task_poolMethod · 0.85
cpu_ctl_envClass · 0.85
get_envMethod · 0.85
scheduler.cppFile · 0.85
allocateMethod · 0.85
push_backMethod · 0.85
resizeMethod · 0.85
arenaMethod · 0.85
arena.cppFile · 0.85
extend_segment_tableMethod · 0.85
market.cppFile · 0.85

Calls 1

throw_exceptionFunction · 0.70

Tested by

no test coverage detected