char*Arena::AllocateAligned(size_tbytes){constintalign=(sizeof(void*)>8)?sizeof(void*):8;//最小8字节对齐assert((align&(align-1))==0);// Pointer size should be a power of 2size_tcurrent_mod=reinterpret_cast<uintptr_t>(alloc_ptr_)&(align-1);//当前指针超出对齐边界的字节数size_tslop=(current_mod==0?0:align-current_mod);//需要调整的字节数size_tneeded=bytes+slop;char*result;if(needed<=alloc_bytes_remaining_){//有足够的剩余内存,就直接分配result=alloc_ptr_+slop;alloc_ptr_+=needed;alloc_bytes_remaining_-=needed;}else{// AllocateFallback always returned aligned memoryresult=AllocateFallback(bytes);//否则就从新分配的一块内存里分配}assert((reinterpret_cast<uintptr_t>(result)&(align-1))==0);returnresult;}