From bffa18befcdb275e5b1d3104c6a80dec56af0f28 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sun, 24 Jan 2010 14:06:07 -0800 Subject: [PATCH] Expose buffer_root() --- src/node_buffer.cc | 4 ---- src/node_buffer.h | 8 ++++++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 584ed184b6..fa11ae42cf 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -32,10 +32,6 @@ bool IsBuffer(v8::Handle val) { } -static inline struct buffer* buffer_root(buffer *buffer) { - return buffer->root ? buffer->root : buffer; -} - /* Determines the absolute position for a relative offset */ static inline size_t buffer_abs_off(buffer *buffer, size_t off) { struct buffer *root = buffer_root(buffer); diff --git a/src/node_buffer.h b/src/node_buffer.h index 3afb3eeaee..2c189fd232 100644 --- a/src/node_buffer.h +++ b/src/node_buffer.h @@ -40,14 +40,18 @@ void InitBuffer(v8::Handle target); struct buffer* BufferUnwrap(v8::Handle val); bool IsBuffer(v8::Handle val); +static inline struct buffer * buffer_root(struct buffer *buffer) { + return buffer->root ? buffer->root : buffer; +} + static inline char * buffer_p(struct buffer *buffer, size_t off) { - struct buffer *root = buffer->root ? buffer->root : buffer; + struct buffer *root = buffer_root(buffer); if (buffer->offset + off >= root->length) return NULL; return reinterpret_cast(&(root->bytes) + buffer->offset + off); } static inline size_t buffer_remaining(struct buffer *buffer, size_t off) { - struct buffer *root = buffer->root ? buffer->root : buffer; + struct buffer *root = buffer_root(buffer); char *end = reinterpret_cast(&(root->bytes) + root->length); return end - buffer_p(buffer, off); }