Skip to content

Commit

Permalink
lib: don't use global Buffer
Browse files Browse the repository at this point in the history
Port of nodejs/node-v0.x-archive#8603

The race condition present in the original PR didn't occur, so no
workaround was needed.

PR-URL: #1794
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
  • Loading branch information
silverwind committed Jun 11, 2015
1 parent ff8202c commit b5b8ff1
Show file tree
Hide file tree
Showing 21 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/_debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const repl = Module.requireRepl();
const inherits = util.inherits;
const assert = require('assert');
const spawn = require('child_process').spawn;
const Buffer = require('buffer').Buffer;

exports.start = function(argv, stdin, stdout) {
argv || (argv = process.argv.slice(2));
Expand Down
1 change: 1 addition & 0 deletions lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const freeParser = common.freeParser;
const debug = common.debug;
const OutgoingMessage = require('_http_outgoing').OutgoingMessage;
const Agent = require('_http_agent');
const Buffer = require('buffer').Buffer;


function ClientRequest(options, cb) {
Expand Down
1 change: 1 addition & 0 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const assert = require('assert').ok;
const Stream = require('stream');
const timers = require('timers');
const util = require('util');
const Buffer = require('buffer').Buffer;
const common = require('_http_common');

const CRLF = common.CRLF;
Expand Down
1 change: 1 addition & 0 deletions lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Readable.ReadableState = ReadableState;

const EE = require('events').EventEmitter;
const Stream = require('stream');
const Buffer = require('buffer').Buffer;
const util = require('util');
const debug = util.debuglog('stream');
var StringDecoder;
Expand Down
1 change: 1 addition & 0 deletions lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Writable.WritableState = WritableState;

const util = require('util');
const Stream = require('stream');
const Buffer = require('buffer').Buffer;

util.inherits(Writable, Stream);

Expand Down
1 change: 1 addition & 0 deletions lib/_tls_legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const tls = require('tls');
const util = require('util');
const common = require('_tls_common');
const debug = util.debuglog('tls-legacy');
const Buffer = require('buffer').Buffer;
const Timer = process.binding('timer_wrap').Timer;
var Connection = null;
try {
Expand Down
1 change: 1 addition & 0 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const util = require('util');
const listenerCount = require('events').listenerCount;
const common = require('_tls_common');
const StreamWrap = require('_stream_wrap').StreamWrap;
const Buffer = require('buffer').Buffer;
const Duplex = require('stream').Duplex;
const debug = util.debuglog('tls');
const Timer = process.binding('timer_wrap').Timer;
Expand Down
1 change: 1 addition & 0 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
// UTILITY
const compare = process.binding('buffer').compare;
const util = require('util');
const Buffer = require('buffer').Buffer;
const pSlice = Array.prototype.slice;

// 1. The assert module provides functions that throw
Expand Down
1 change: 1 addition & 0 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const constants = require('constants');

const uv = process.binding('uv');
const spawn_sync = process.binding('spawn_sync');
const Buffer = require('buffer').Buffer;
const Pipe = process.binding('pipe_wrap').Pipe;
const child_process = require('internal/child_process');

Expand Down
1 change: 1 addition & 0 deletions lib/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ try {
throw new Error('node.js not compiled with openssl crypto support.');
}

const Buffer = require('buffer').Buffer;
const constants = require('constants');
const stream = require('stream');
const util = require('util');
Expand Down
1 change: 1 addition & 0 deletions lib/dgram.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const assert = require('assert');
const Buffer = require('buffer').Buffer;
const util = require('util');
const events = require('events');
const constants = require('constants');
Expand Down
1 change: 1 addition & 0 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const pathModule = require('path');
const binding = process.binding('fs');
const constants = require('constants');
const fs = exports;
const Buffer = require('buffer').Buffer;
const Stream = require('stream').Stream;
const EventEmitter = require('events').EventEmitter;
const FSReqWrap = binding.FSReqWrap;
Expand Down
1 change: 1 addition & 0 deletions lib/internal/child_process.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const StringDecoder = require('string_decoder').StringDecoder;
const Buffer = require('buffer').Buffer;
const EventEmitter = require('events').EventEmitter;
const net = require('net');
const dgram = require('dgram');
Expand Down
1 change: 1 addition & 0 deletions lib/internal/smalloc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const smalloc = process.binding('smalloc');
const Buffer = require('buffer').Buffer;
const kMaxLength = smalloc.kMaxLength;
const kMinType = smalloc.kMinType;
const kMaxType = smalloc.kMaxType;
Expand Down
1 change: 1 addition & 0 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const assert = require('assert');
const cares = process.binding('cares_wrap');
const uv = process.binding('uv');

const Buffer = require('buffer').Buffer;
const TTYWrap = process.binding('tty_wrap');
const TCP = process.binding('tcp_wrap').TCP;
const Pipe = process.binding('pipe_wrap').Pipe;
Expand Down
1 change: 1 addition & 0 deletions lib/querystring.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
'use strict';

const QueryString = exports;
const Buffer = require('buffer').Buffer;


function charCode(c) {
Expand Down
1 change: 1 addition & 0 deletions lib/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const kHistorySize = 30;

const util = require('util');
const inherits = util.inherits;
const Buffer = require('buffer').Buffer;
const EventEmitter = require('events').EventEmitter;


Expand Down
2 changes: 2 additions & 0 deletions lib/string_decoder.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const Buffer = require('buffer').Buffer;

function assertEncoding(encoding) {
// Do not cache `Buffer.isEncoding`, some modules monkey-patch it to support
// additional encodings
Expand Down
1 change: 1 addition & 0 deletions lib/tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const net = require('net');
const url = require('url');
const util = require('util');
const binding = process.binding('crypto');
const Buffer = require('buffer').Buffer;

// Allow {CLIENT_RENEG_LIMIT} client-initiated session renegotiations
// every {CLIENT_RENEG_WINDOW} seconds. An error event is emitted if more
Expand Down
1 change: 1 addition & 0 deletions lib/util.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const uv = process.binding('uv');
const Buffer = require('buffer').Buffer;
const Debug = require('vm').runInDebugContext('Debug');
const internalUtil = require('internal/util');

Expand Down
1 change: 1 addition & 0 deletions lib/zlib.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const Buffer = require('buffer').Buffer;
const Transform = require('_stream_transform');
const binding = process.binding('zlib');
const util = require('util');
Expand Down

0 comments on commit b5b8ff1

Please sign in to comment.