Skip to content

doc: fixed misinformation in Buffer.allocUnsafe method

Rodrigo Muino Tomonari requested to merge github/fork/mertcanaltin/dev-50635 into main

issue: #50635 (closed)

Changes Made: Corrected the documentation regarding Buffer.allocUnsafe method by adding missing information. The discrepancy was identified in the logic for pre-allocating an internal Buffer. The documentation stated:

... only when size is less than or equal to Buffer.poolSize >> 1 (floor of Buffer.poolSize divided by two).

However, the actual code implementation uses:

if (size < (Buffer.poolSize >>> 1)) {

I have updated the documentation to accurately reflect the code logic.

Affected URL(s):

https://nodejs.org/dist/latest-v20.x/docs/api/buffer.html#static-method-bufferallocunsafesize

Merge request reports

Loading