Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Expose buffer_root()

  • Loading branch information...
commit bffa18befcdb275e5b1d3104c6a80dec56af0f28 1 parent 42ee169
@ry ry authored
Showing with 6 additions and 6 deletions.
  1. +0 −4 src/node_buffer.cc
  2. +6 −2 src/node_buffer.h
View
4 src/node_buffer.cc
@@ -32,10 +32,6 @@ bool IsBuffer(v8::Handle<v8::Value> 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);
View
8 src/node_buffer.h
@@ -40,14 +40,18 @@ void InitBuffer(v8::Handle<v8::Object> target);
struct buffer* BufferUnwrap(v8::Handle<v8::Value> val);
bool IsBuffer(v8::Handle<v8::Value> 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<char*>(&(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<char*>(&(root->bytes) + root->length);
return end - buffer_p(buffer, off);
}
Please sign in to comment.
Something went wrong with that request. Please try again.