expose strlen from Foreign.C.String
Viktor Dukhovni
ietf-dane at dukhovni.org
Fri Jan 22 20:31:22 UTC 2021
On Fri, Jan 22, 2021 at 08:45:54AM -0500, Andrew Martin wrote:
> x <- malloc ...
> memcpy ... copy a nul-terminated string into x
> let len = cstringLength x
> free x
Isn't this broadly true for general uses of CString? Which is why we
have `withCString`:
https://hackage.haskell.org/package/base-4.14.1.0/docs/Foreign-C-String.html#v:withCString
Is there any particularly different about the proposed `cstringLength`?
Are you suggesting that it should have an "IO Int" result type to force
sequencing? Is this warranted? Shouldn't users of CString (Ptr CChar)
be already aware of the liveness issue in general.
--
Viktor.
More information about the Libraries
mailing list