Re: allocate memory to Char **

Lamine <[email protected]> Tue, 29 Apr 2014 15:07:54 +0200
Newsgroups gmane.comp.lang.haskell.ffi
Message-ID <[email protected]>
I try pokeElemOff but i have same error "segmentation fault(core =

dumped)". Thank for your response!
On 04/29/2014 01:30 PM, Henning Thielemann wrote:
> Am 29.04.2014 13:11, schrieb Lamine:
>
>> I try this code unsing mallocList to (http://lpaste.net/report/712):
>> mallocList :: [CString] -> IO (Ptr CString)
>> mallocList xs =3D do let n =3D Prelude.length xs
>>                     p <- mallocBytes (n*100)
>>                     forM_ (Prelude.zip [0..] xs)
>>                      (uncurry (pokeByteOff p))
>
> I guess this must be pokeElemOff.
>
>>                     return p
>>
>> let n =3D sizeOf(undefined :: CString)
>>             allocaArray w $ \var -> do
>>                    xs <- peekArray (w*n) var
>>                    varnames <- mallocList xs
>>
>> I have an error "segmentation fault(core dumped)".
>> can someone please help me? Thank you.
>


-- =

=AB Chaque g=E9n=E9ration doit, dans un =E9tat relatif de captivit=E9, d=E9=
couvrir =

sa mission. Elle a le choix de la remplir ou la trahir=BB. Frantz Fanon