diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2016-06-28 21:21:21 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2016-06-28 21:21:21 +0200 |
commit | 97aeb0ae12d334263b9ba3084b06d994513ef76a (patch) | |
tree | a6dfe8133896439e778ce2eb80c1e9e2ad1f4ce1 /src/util.h | |
parent | 0daffdf3fd9a505234c6bc7fed3d3118ff3331e4 (diff) | |
download | android-node-v8-97aeb0ae12d334263b9ba3084b06d994513ef76a.tar.gz android-node-v8-97aeb0ae12d334263b9ba3084b06d994513ef76a.tar.bz2 android-node-v8-97aeb0ae12d334263b9ba3084b06d994513ef76a.zip |
src: fix whitespace/indent cpplint warnings
PR-URL: https://github.com/nodejs/node/pull/7462
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'src/util.h')
-rw-r--r-- | src/util.h | 162 |
1 files changed, 81 insertions, 81 deletions
diff --git a/src/util.h b/src/util.h index dd2da89e4e..0a6b5e0dbe 100644 --- a/src/util.h +++ b/src/util.h @@ -213,99 +213,99 @@ inline bool StringEqualNoCaseN(const char* a, const char* b, size_t length); // the stack is used, otherwise malloc(). template <typename T, size_t kStackStorageSize = 1024> class MaybeStackBuffer { - public: - const T* out() const { - return buf_; - } - - T* out() { - return buf_; - } - - // operator* for compatibility with `v8::String::(Utf8)Value` - T* operator*() { - return buf_; - } - - const T* operator*() const { - return buf_; - } - - size_t length() const { - return length_; - } - - // Call to make sure enough space for `storage` entries is available. - // There can only be 1 call to AllocateSufficientStorage or Invalidate - // per instance. - void AllocateSufficientStorage(size_t storage) { - if (storage <= kStackStorageSize) { - buf_ = buf_st_; - } else { - // Guard against overflow. - CHECK_LE(storage, sizeof(T) * storage); - - buf_ = static_cast<T*>(malloc(sizeof(T) * storage)); - CHECK_NE(buf_, nullptr); - } - - // Remember how much was allocated to check against that in SetLength(). - length_ = storage; - } - - void SetLength(size_t length) { - // length_ stores how much memory was allocated. - CHECK_LE(length, length_); - length_ = length; - } - - void SetLengthAndZeroTerminate(size_t length) { - // length_ stores how much memory was allocated. - CHECK_LE(length + 1, length_); - SetLength(length); - - // T() is 0 for integer types, nullptr for pointers, etc. - buf_[length] = T(); - } - - // Make derefencing this object return nullptr. - // Calling this is mutually exclusive with calling - // AllocateSufficientStorage. - void Invalidate() { - CHECK_EQ(buf_, buf_st_); - length_ = 0; - buf_ = nullptr; - } - - MaybeStackBuffer() : length_(0), buf_(buf_st_) { - // Default to a zero-length, null-terminated buffer. - buf_[0] = T(); + public: + const T* out() const { + return buf_; + } + + T* out() { + return buf_; + } + + // operator* for compatibility with `v8::String::(Utf8)Value` + T* operator*() { + return buf_; + } + + const T* operator*() const { + return buf_; + } + + size_t length() const { + return length_; + } + + // Call to make sure enough space for `storage` entries is available. + // There can only be 1 call to AllocateSufficientStorage or Invalidate + // per instance. + void AllocateSufficientStorage(size_t storage) { + if (storage <= kStackStorageSize) { + buf_ = buf_st_; + } else { + // Guard against overflow. + CHECK_LE(storage, sizeof(T) * storage); + + buf_ = static_cast<T*>(malloc(sizeof(T) * storage)); + CHECK_NE(buf_, nullptr); } - ~MaybeStackBuffer() { - if (buf_ != buf_st_) - free(buf_); - } + // Remember how much was allocated to check against that in SetLength(). + length_ = storage; + } + + void SetLength(size_t length) { + // length_ stores how much memory was allocated. + CHECK_LE(length, length_); + length_ = length; + } + + void SetLengthAndZeroTerminate(size_t length) { + // length_ stores how much memory was allocated. + CHECK_LE(length + 1, length_); + SetLength(length); + + // T() is 0 for integer types, nullptr for pointers, etc. + buf_[length] = T(); + } + + // Make derefencing this object return nullptr. + // Calling this is mutually exclusive with calling + // AllocateSufficientStorage. + void Invalidate() { + CHECK_EQ(buf_, buf_st_); + length_ = 0; + buf_ = nullptr; + } + + MaybeStackBuffer() : length_(0), buf_(buf_st_) { + // Default to a zero-length, null-terminated buffer. + buf_[0] = T(); + } + + ~MaybeStackBuffer() { + if (buf_ != buf_st_) + free(buf_); + } - private: - size_t length_; - T* buf_; - T buf_st_[kStackStorageSize]; + private: + size_t length_; + T* buf_; + T buf_st_[kStackStorageSize]; }; class Utf8Value : public MaybeStackBuffer<char> { - public: - explicit Utf8Value(v8::Isolate* isolate, v8::Local<v8::Value> value); + public: + explicit Utf8Value(v8::Isolate* isolate, v8::Local<v8::Value> value); }; class TwoByteValue : public MaybeStackBuffer<uint16_t> { - public: - explicit TwoByteValue(v8::Isolate* isolate, v8::Local<v8::Value> value); + public: + explicit TwoByteValue(v8::Isolate* isolate, v8::Local<v8::Value> value); }; class BufferValue : public MaybeStackBuffer<char> { - public: - explicit BufferValue(v8::Isolate* isolate, v8::Local<v8::Value> value); + public: + explicit BufferValue(v8::Isolate* isolate, v8::Local<v8::Value> value); }; } // namespace node |