Skip to content

Commit 5586cec

Browse files
bnoordhuisrvagg
authored andcommitted
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: #2308 PR-URL: #2352 Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Trevor Norris <[email protected]>
1 parent bff9bcd commit 5586cec

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

src/node_buffer.h

-22
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
#include "node.h"
55
#include "v8.h"
66

7-
#if defined(NODE_WANT_INTERNALS)
8-
#include "env.h"
9-
#endif // defined(NODE_WANT_INTERNALS)
10-
117
namespace node {
128
namespace Buffer {
139

@@ -63,24 +59,6 @@ static inline bool IsWithinBounds(size_t off, size_t len, size_t max) {
6359
return true;
6460
}
6561

66-
// Internal. Not for public consumption. We can't define these
67-
// in src/node_internals.h because of a circular dependency.
68-
#if defined(NODE_WANT_INTERNALS)
69-
v8::MaybeLocal<v8::Object> New(Environment* env, size_t size);
70-
// Makes a copy of |data|.
71-
v8::MaybeLocal<v8::Object> New(Environment* env, const char* data, size_t len);
72-
// Takes ownership of |data|.
73-
v8::MaybeLocal<v8::Object> New(Environment* env,
74-
char* data,
75-
size_t length,
76-
FreeCallback callback,
77-
void* hint);
78-
// Takes ownership of |data|. Must allocate |data| with malloc() or realloc()
79-
// because ArrayBufferAllocator::Free() deallocates it again with free().
80-
// Mixing operator new and free() is undefined behavior so don't do that.
81-
v8::MaybeLocal<v8::Object> Use(Environment* env, char* data, size_t length);
82-
#endif // defined(NODE_WANT_INTERNALS)
83-
8462
} // namespace Buffer
8563
} // namespace node
8664

src/node_internals.h

+16
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,22 @@ class NodeInstanceData {
272272
DISALLOW_COPY_AND_ASSIGN(NodeInstanceData);
273273
};
274274

275+
namespace Buffer {
276+
v8::MaybeLocal<v8::Object> New(Environment* env, size_t size);
277+
// Makes a copy of |data|.
278+
v8::MaybeLocal<v8::Object> New(Environment* env, const char* data, size_t len);
279+
// Takes ownership of |data|.
280+
v8::MaybeLocal<v8::Object> New(Environment* env,
281+
char* data,
282+
size_t length,
283+
void (*callback)(char* data, void* hint),
284+
void* hint);
285+
// Takes ownership of |data|. Must allocate |data| with malloc() or realloc()
286+
// because ArrayBufferAllocator::Free() deallocates it again with free().
287+
// Mixing operator new and free() is undefined behavior so don't do that.
288+
v8::MaybeLocal<v8::Object> Use(Environment* env, char* data, size_t length);
289+
} // namespace Buffer
290+
275291
} // namespace node
276292

277293
#endif // SRC_NODE_INTERNALS_H_

0 commit comments

Comments
 (0)