|
Re: [GHC] #869: Foreign.C.String.withCStringLen doesn't terminate C string : msg#00121lang.haskell.glasgow.bugs
#869: Foreign.C.String.withCStringLen doesn't terminate C string by NUL -----------------------------+---------------------------------------------- Reporter: guest | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: libraries/base | Version: 6.4.2 Severity: normal | Resolution: Keywords: | Os: Linux Difficulty: Unknown | Architecture: x86 -----------------------------+---------------------------------------------- Comment (by duncan): From my reading of the FFI spec CStringLen is not required to be nul terminated. So I think the code is correct and the documentation is wrong. {{{ type CString = Ptr CChar A C string is a reference to an array of C characters terminated by NUL. type CStringLen = (Ptr CChar, Int) In addition to NUL-terminated strings, the module CString also supports strings with explicit length information in bytes. newCString :: String -> IO CString newCStringLen :: String -> IO CStringLen Allocate a memory area for a Haskell string and marshal the string into its C representation. There are two variants of the routine, one for each supported string representation. withCString :: String -> (CString -> IO a) -> IO a withCStringLen :: String -> (CStringLen -> IO a) -> IO a These two routines operate as newCString and newCStringLen, respectively, but handle memory allocation and deallocation like MarshalAlloc.alloca (Section 5.8). }}} -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/869> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler_______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@xxxxxxxxxxx http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | [GHC] #869: Foreign.C.String.withCStringLen doesn't terminate C string by NUL, GHC |
|---|---|
| Next by Date: | Re: [GHC] #869: Foreign.C.String.withCStringLen doesn't terminate C string by NUL, GHC |
| Previous by Thread: | [GHC] #869: Foreign.C.String.withCStringLen doesn't terminate C string by NUL, GHC |
| Next by Thread: | Re: [GHC] #869: Foreign.C.String.withCStringLen doesn't terminate C string by NUL, GHC |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |