GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — buffer: implement Uint8Array backed Buffer · nodejs/node@63da0df

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • buffer.js
    • internal
      • buffer_new.js
      • buffer_old.js
  • node.gyp
  • src
    • env.h
    • node.cc
    • node_buffer.cc
    • node_buffer.h
    • node_internals.h
    • util-inl.h
    • util.h
  • test/parallel
    • test-buffer-slice.js
    • test-buffer.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/buffer.js‎

Copy file name to clipboardExpand all lines: lib/buffer.js
+4-1,145Lines changed: 4 additions & 1145 deletions
Large diffs are not rendered by default.
Collapse file

‎lib/internal/buffer_new.js‎

Copy file name to clipboardExpand all lines: lib/internal/buffer_new.js
+1,020Lines changed: 1020 additions & 0 deletions
Large diffs are not rendered by default.
Collapse file

‎lib/internal/buffer_old.js‎

Copy file name to clipboardExpand all lines: lib/internal/buffer_old.js
+1,140Lines changed: 1140 additions & 0 deletions
Large diffs are not rendered by default.
Collapse file

‎node.gyp‎

Copy file name to clipboardExpand all lines: node.gyp
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@
6969
'lib/v8.js',
7070
'lib/vm.js',
7171
'lib/zlib.js',
72-
7372
'lib/internal/child_process.js',
73+
'lib/internal/buffer_old.js',
74+
'lib/internal/buffer_new.js',
7475
'lib/internal/freelist.js',
7576
'lib/internal/smalloc.js',
7677
'lib/internal/socket_list.js',
Collapse file

‎src/env.h‎

Copy file name to clipboardExpand all lines: src/env.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ namespace node {
231231
V(async_hooks_post_function, v8::Function) \
232232
V(binding_cache_object, v8::Object) \
233233
V(buffer_constructor_function, v8::Function) \
234+
V(buffer_prototype_object, v8::Object) \
234235
V(context, v8::Context) \
235236
V(domain_array, v8::Array) \
236237
V(fs_stats_constructor_function, v8::Function) \
Collapse file

‎src/node.cc‎

Copy file name to clipboardExpand all lines: src/node.cc
+16-9Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "node_http_parser.h"
66
#include "node_javascript.h"
77
#include "node_version.h"
8+
#include "node_internals.h"
89

910
#if defined HAVE_PERFCTR
1011
#include "node_counters.h"
@@ -147,6 +148,8 @@ static uv_async_t dispatch_debug_messages_async;
147148
static Isolate* node_isolate = nullptr;
148149
static v8::Platform* default_platform;
149150

151+
bool using_old_buffer = false;
152+
150153
class ArrayBufferAllocator : public ArrayBuffer::Allocator {
151154
public:
152155
// Impose an upper limit to avoid out of memory errors that bring down
@@ -166,23 +169,17 @@ ArrayBufferAllocator ArrayBufferAllocator::the_singleton;
166169

167170

168171
void* ArrayBufferAllocator::Allocate(size_t length) {
169-
if (length > kMaxLength)
170-
return nullptr;
171-
char* data = new char[length];
172-
memset(data, 0, length);
173-
return data;
172+
return calloc(length, 1);
174173
}
175174

176175

177176
void* ArrayBufferAllocator::AllocateUninitialized(size_t length) {
178-
if (length > kMaxLength)
179-
return nullptr;
180-
return new char[length];
177+
return malloc(length);
181178
}
182179

183180

184181
void ArrayBufferAllocator::Free(void* data, size_t length) {
185-
delete[] static_cast<char*>(data);
182+
free(data);
186183
}
187184

188185

@@ -2836,6 +2833,11 @@ void SetupProcessObject(Environment* env,
28362833
READONLY_PROPERTY(process, "traceDeprecation", True(env->isolate()));
28372834
}
28382835

2836+
// --use-old_buffer
2837+
if (using_old_buffer) {
2838+
READONLY_PROPERTY(process, "useOldBuffer", True(env->isolate()));
2839+
}
2840+
28392841
size_t exec_path_len = 2 * PATH_MAX;
28402842
char* exec_path = new char[exec_path_len];
28412843
Local<String> exec_path_value;
@@ -3067,6 +3069,7 @@ static void PrintHelp() {
30673069
" --track-heap-objects track heap object allocations for heap "
30683070
"snapshots\n"
30693071
" --v8-options print v8 command line options\n"
3072+
" --use-old-buffer Revert to old Buffer implementation\n"
30703073
#if defined(NODE_HAVE_I18N_SUPPORT)
30713074
" --icu-data-dir=dir set ICU data load path to dir\n"
30723075
" (overrides NODE_ICU_DATA)\n"
@@ -3204,6 +3207,10 @@ static void ParseArgs(int* argc,
32043207
#endif
32053208
} else if (strcmp(arg, "--expose-internals") == 0 ||
32063209
strcmp(arg, "--expose_internals") == 0) {
3210+
} else if (strcmp(arg, "--use-old-buffer") == 0 ||
3211+
strcmp(arg, "--use_old_buffer") == 0) {
3212+
using_old_buffer = true;
3213+
32073214
// consumed in js
32083215
} else {
32093216
// V8 option. Pass through as-is.

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.