allocate memory to Char **
Lamine
mohamadoulamine at gmail.com
Tue Apr 29 13:07:54 UTC 2014
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 = do let n = 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 = 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.
>
--
« Chaque génération doit, dans un état relatif de captivité, découvrir
sa mission. Elle a le choix de la remplir ou la trahir». Frantz Fanon
More information about the FFI
mailing list