Skip to content

Commit

Permalink
dgram: use Buffer.alloc(0) for zero-size buffers
Browse files Browse the repository at this point in the history
There is no difference between alloc(0) and allocUnsafe(0), so there is
no reason to confuse anyone reading the code with an additional call to
allocUnsafe.

PR-URL: #8751
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ilkka Myller <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
  • Loading branch information
ChALkeR authored and Fishrock123 committed Oct 11, 2016
1 parent 9b0733f commit c4d9b54
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ Socket.prototype.send = function(buffer,
self.bind({port: 0, exclusive: true}, null);

if (list.length === 0)
list.push(Buffer.allocUnsafe(0));
list.push(Buffer.alloc(0));

// If the socket hasn't been bound yet, push the outbound packet onto the
// send queue and send after binding is complete.
Expand Down

0 comments on commit c4d9b54

Please sign in to comment.