Re: expose strlen from Foreign.C.String

Viktor Dukhovni <[email protected]>
Newsgroups gmane.comp.lang.haskell.libraries
Message-ID <[email protected]>
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.
_______________________________________________
Libraries mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.