summaryrefslogtreecommitdiff
path: root/src/node_buffer.h
diff options
context:
space:
mode:
authorStéphan Kochen <stephan@kochen.nl>2010-10-22 12:08:55 +0200
committerRyan Dahl <ry@tinyclouds.org>2010-10-22 16:52:14 -0700
commitdd5273747670bf1be250df7b84525096e1d23775 (patch)
tree4f32981b0224b75ca7cc63befc41798310cd2286 /src/node_buffer.h
parentb3e60c7b253727a4075fdffa8714527a50673b74 (diff)
downloadnode-dd5273747670bf1be250df7b84525096e1d23775.tar.gz
Provide a C++ Buffer constructor for external storage.
In order to do this, buffer data management was moved out of the JS entry-point New, and into Replace. Secondly, the constructor makes an immediate call to Replace, and in order for ArrayData calls to work, wrapping must already be set up. Now, the constructor takes the wrappee as a parameter.
Diffstat (limited to 'src/node_buffer.h')
-rw-r--r--src/node_buffer.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/node_buffer.h b/src/node_buffer.h
index 5fa8c8aa5..3221417f2 100644
--- a/src/node_buffer.h
+++ b/src/node_buffer.h
@@ -22,9 +22,13 @@ class Buffer : public ObjectWrap {
public:
~Buffer();
+ typedef void (*free_callback)(char *data, void *hint);
+
static void Initialize(v8::Handle<v8::Object> target);
static Buffer* New(size_t length); // public constructor
static Buffer* New(char *data, size_t len); // public constructor
+ static Buffer* New(char *data, size_t length,
+ free_callback callback, void *hint); // public constructor
static bool HasInstance(v8::Handle<v8::Value> val);
static char* Data(v8::Handle<v8::Object>);
@@ -56,10 +60,13 @@ class Buffer : public ObjectWrap {
static v8::Handle<v8::Value> MakeFastBuffer(const v8::Arguments &args);
static v8::Handle<v8::Value> Copy(const v8::Arguments &args);
- Buffer(size_t length);
+ Buffer(v8::Handle<v8::Object> wrapper, size_t length);
+ void Replace(char *data, size_t length, free_callback callback, void *hint);
size_t length_;
char* data_;
+ free_callback callback_;
+ void* callback_hint_;
};