void* memory_reallocate( void* p, uint64_t size, unsigned int align ) { FOUNDATION_ASSERT_MSG( ( p < _memory_temporary.storage ) || ( p >= _memory_temporary.end ), "Trying to reallocate temporary memory" ); _memory_untrack( p ); p = _memsys.reallocate( p, size, align ); _memory_track( p, size ); return p; }
void* memory_allocate( uint64_t size, unsigned int align, memory_hint_t hint ) { void* p; if( ( hint == MEMORY_TEMPORARY ) && _memory_temporary.storage && ( size + align < _memory_temporary.maxchunk ) ) { align = _memory_get_align( align ); p = _memory_align_pointer( _atomic_allocate_linear( size + align ), align ); } else { p = _memsys.allocate( memory_context(), size, align, hint ); } _memory_track( p, size ); return p; }
void* memory_allocate(hash_t context, size_t size, unsigned int align, unsigned int hint) { void* p = 0; if (_memory_temporary.storage && (hint & MEMORY_TEMPORARY)) { unsigned int tmpalign = _memory_get_align_forced(align); if (size + tmpalign < _memory_temporary.maxchunk) { p = _memory_align_pointer(_atomic_allocate_linear(size + tmpalign), tmpalign); FOUNDATION_ASSERT(!((uintptr_t)p & 1)); if (hint & MEMORY_ZERO_INITIALIZED) memset(p, 0, (size_t)size); } } if (!p) p = _memory_system.allocate(context ? context : memory_context(), size, align, hint); _memory_track(p, size); return p; }
void* memory_allocate( uint64_t context, uint64_t size, unsigned int align, int hint ) { void* p; if( ( hint & MEMORY_TEMPORARY ) && _memory_temporary.storage && ( size + align < _memory_temporary.maxchunk ) ) { align = _memory_get_align( align ); if( align < FOUNDATION_SIZE_POINTER ) align = FOUNDATION_SIZE_POINTER; p = _memory_align_pointer( _atomic_allocate_linear( size + align ), align ); FOUNDATION_ASSERT( !( (uintptr_t)p & 1 ) ); memset( p, 0, (size_t)size ); } else { p = _memory_system.allocate( context ? context : memory_context(), size, align, hint ); } _memory_track( p, size ); return p; }
void* memory_allocate_zero_context( uint16_t context, uint64_t size, unsigned int align, memory_hint_t hint ) { void* p = _memsys.allocate_zero( context, size, align, hint ); _memory_track( p, size ); return p; }