From: krasimir Date: Fri, 24 Dec 2004 12:20:18 +0000 (+0000) Subject: [project @ 2004-12-24 12:20:18 by krasimir] X-Git-Tag: nhc98-1-18-release~147 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=f498141ce5e5bfa843a374e82a6f5f2d0529a4d1;p=haskell-directory.git [project @ 2004-12-24 12:20:18 by krasimir] revert the previous commit it was wrong --- diff --git a/Foreign/C/String.hs b/Foreign/C/String.hs index 720330c..b03d32b 100644 --- a/Foreign/C/String.hs +++ b/Foreign/C/String.hs @@ -278,10 +278,12 @@ newCAStringLen str = do newCAStringLen str = do ptr <- mallocArray0 len let - go [] n = n `seq` return n -- make it strict in n + go [] n = n `seq` return () -- make it strict in n go (c:cs) n = do pokeElemOff ptr n (castCharToCChar c); go cs (n+1) - len <- go str 0 + go str 0 return (ptr, len) + where + len = length str #endif -- | Marshal a Haskell string into a NUL terminated C string using temporary @@ -323,11 +325,13 @@ withCAStringLen str act = withArray (charsToCChars str) $ act . pairLength str withCAStringLen str f = allocaArray len $ \ptr -> let - go [] n = n `seq` return n -- make it strict in n + go [] n = n `seq` return () -- make it strict in n go (c:cs) n = do pokeElemOff ptr n (castCharToCChar c); go cs (n+1) in do - len <- go str 0 + go str 0 f (ptr,len) + where + len = length str #endif -- auxiliary definitions