[英]Does Haskell's `Data.Vector.Mutable.unsafeNew` zero the memory?
The docs says that new
"creates a mutable vector of the given length" and unsafeNew
"creates a mutable vector of the given length. The length is not checked." 文档说
new
“创建给定长度的可变向量”和unsafeNew
“创建给定长度的可变向量。不检查长度。”
However this resolved github issue indicates that unsafeNew
does not zero the memory while new
does. 但是, 这个解决的github问题表明
unsafeNew
不会将内存归零,而new
unsafeNew
。
Which one is it? 哪一个?
No, not in general. 不,不是一般的。 If you click through the source this is pretty clear:
如果你点击源代码,这很清楚:
https://hackage.haskell.org/package/vector-0.11.0.0/docs/src/Data-Vector-Generic-Mutable.html#new https://hackage.haskell.org/package/vector-0.11.0.0/docs/src/Data-Vector-Generic-Mutable.html#new
new
is unsafeNew
with the addition of basicInitialize
. new
是unsafeNew
的新增了basicInitialize
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.