X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FArena.h;h=f2af34e477556d1c74f6d5c28c897097f4624373;hb=d08270e6cbc374ef67b55f21beed0cfcc359d0e1;hp=2b93aa344547fd658cb0a3477a3c3d7c826498ef;hpb=ce64f0f685111ac24c7a321ea56d0c3524621df1;p=folly.git diff --git a/folly/Arena.h b/folly/Arena.h index 2b93aa34..f2af34e4 100644 --- a/folly/Arena.h +++ b/folly/Arena.h @@ -1,5 +1,5 @@ /* - * Copyright 2014 Facebook, Inc. + * Copyright 2015 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,7 +84,8 @@ class Arena { size = roundUp(size); bytesUsed_ += size; - if (LIKELY(end_ - ptr_ >= size)) { + assert(ptr_ <= end_); + if (LIKELY((size_t)(end_ - ptr_) >= size)) { // Fast path: there's enough room in the current block char* r = ptr_; ptr_ += size; @@ -149,7 +150,7 @@ class Arena { private: Block() { } ~Block() { } - } __attribute__((aligned)); + } __attribute__((__aligned__)); // This should be alignas(std::max_align_t) but neither alignas nor // max_align_t are supported by gcc 4.6.2. @@ -157,6 +158,7 @@ class Arena { static constexpr size_t kDefaultMinBlockSize = 4096 - sizeof(Block); static constexpr size_t kNoSizeLimit = 0; static constexpr size_t kDefaultMaxAlign = alignof(Block); + static constexpr size_t kBlockOverhead = sizeof(Block); private: bool isAligned(uintptr_t address) const {