Skip to content

sizeofByteArray# returns allocated words, not requested length in bytes

A byte array allocated with (GHC.Prim.newByteArray# 7) will report it's size as '8' - that is, the stored size in StgArrWords is the number of allocated words, not the number of requested bytes.

This menas that if I want to a GHC.Prim.ByteArray# or MutableByteArray# as an array type, I need a separate length fields.

See also: http://www.haskell.org/pipermail/glasgow-haskell-users/2009-December/018199.html

Edited by Ian Lynagh -
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information