Skip to content

Commit c4d9b54

Browse files
ChALkeRFishrock123
authored andcommitted
dgram: use Buffer.alloc(0) for zero-size buffers
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 <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 9b0733f commit c4d9b54

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/dgram.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ Socket.prototype.send = function(buffer,
353353
self.bind({port: 0, exclusive: true}, null);
354354

355355
if (list.length === 0)
356-
list.push(Buffer.allocUnsafe(0));
356+
list.push(Buffer.alloc(0));
357357

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

0 commit comments

Comments
 (0)