diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2015-08-13 14:29:28 +0300 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2015-08-13 21:04:54 +0300 |
commit | b86211a8b62c8f8ba7eed280ce7dcdf7d113cbe9 (patch) | |
tree | d040367fa0c8c4da5280ede9afd04fe166ed6201 | |
parent | 64577463dfbc7ebe646c6c5a06e4b309b2757205 (diff) |
src: move internal functions out of node_buffer.h
The circular dependency problem that put them there in the first place
is no longer an issue. Move them out of the public node_buffer.h header
and into the private node_internals.h header.
Fixes: https://github.com/nodejs/node/issues/2308
PR-URL: https://github.com/nodejs/node/pull/2352
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
-rw-r--r-- | src/node_buffer.h | 22 | ||||
-rw-r--r-- | src/node_internals.h | 16 |
2 files changed, 16 insertions, 22 deletions
diff --git a/src/node_buffer.h b/src/node_buffer.h index f7c88f60e03..49fb5741640 100644 --- a/src/node_buffer.h +++ b/src/node_buffer.h @@ -4,10 +4,6 @@ #include "node.h" #include "v8.h" -#if defined(NODE_WANT_INTERNALS) -#include "env.h" -#endif // defined(NODE_WANT_INTERNALS) - namespace node { namespace Buffer { @@ -63,24 +59,6 @@ static inline bool IsWithinBounds(size_t off, size_t len, size_t max) { return true; } -// Internal. Not for public consumption. We can't define these -// in src/node_internals.h because of a circular dependency. -#if defined(NODE_WANT_INTERNALS) -v8::MaybeLocal<v8::Object> New(Environment* env, size_t size); -// Makes a copy of |data|. -v8::MaybeLocal<v8::Object> New(Environment* env, const char* data, size_t len); -// Takes ownership of |data|. -v8::MaybeLocal<v8::Object> New(Environment* env, - char* data, - size_t length, - FreeCallback callback, - void* hint); -// Takes ownership of |data|. Must allocate |data| with malloc() or realloc() -// because ArrayBufferAllocator::Free() deallocates it again with free(). -// Mixing operator new and free() is undefined behavior so don't do that. -v8::MaybeLocal<v8::Object> Use(Environment* env, char* data, size_t length); -#endif // defined(NODE_WANT_INTERNALS) - } // namespace Buffer } // namespace node diff --git a/src/node_internals.h b/src/node_internals.h index c99b2feeb0b..aa4474becc1 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -272,6 +272,22 @@ class NodeInstanceData { DISALLOW_COPY_AND_ASSIGN(NodeInstanceData); }; +namespace Buffer { +v8::MaybeLocal<v8::Object> New(Environment* env, size_t size); +// Makes a copy of |data|. +v8::MaybeLocal<v8::Object> New(Environment* env, const char* data, size_t len); +// Takes ownership of |data|. +v8::MaybeLocal<v8::Object> New(Environment* env, + char* data, + size_t length, + void (*callback)(char* data, void* hint), + void* hint); +// Takes ownership of |data|. Must allocate |data| with malloc() or realloc() +// because ArrayBufferAllocator::Free() deallocates it again with free(). +// Mixing operator new and free() is undefined behavior so don't do that. +v8::MaybeLocal<v8::Object> Use(Environment* env, char* data, size_t length); +} // namespace Buffer + } // namespace node #endif // SRC_NODE_INTERNALS_H_ |