Wed, 16 Aug 2000 07:32:48 -0700, Simon Marlow <[EMAIL PROTECTED]> pisze:
> I'm not sure I understand; how does autoPtrToBytes work if it
> doesn't use a ForeignObj?
autoPtrToBytes:: Int -> IO (Ptr a)
autoPtrToBytes size = do
ptr <- mallocBytes size
addFinalizer ptr (free ptr)
return ptr
> If you need internal pointers to a structure pointed to by a
> ForeignObj, then you'll need an arrangement of weak pointers to
> guarantee that the outer object is kept alive while the internal
> pointer is still in use. (actually the internal pointer could be
> a ForeignObj with a finalizer which just touches the outer object).
Ah, indeed. So plusAddr variants theoretically could be made safe,
while permitting attaching freeing finalizers to Addrs - but it would
be too expensive for every use, as in many cases touch placed after
the last use of the inner object is enough.
--
__("< Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
\__/
^^ SYGNATURA ZASTĘPCZA
QRCZAK
- Accessing ForeignObj contents from Haskell Marcin 'Qrczak' Kowalczyk
- RE: Accessing ForeignObj contents from Hask... Simon Marlow
- Re: Accessing ForeignObj contents from ... Marcin 'Qrczak' Kowalczyk
- Re: Accessing ForeignObj contents f... Marcin 'Qrczak' Kowalczyk
- Re: Accessing ForeignObj conten... Marcin 'Qrczak' Kowalczyk
- RE: Accessing ForeignObj contents from Hask... Simon Marlow
- RE: Accessing ForeignObj contents from ... Manuel M. T. Chakravarty
- RE: Accessing ForeignObj contents from Hask... Simon Marlow
- Re: Accessing ForeignObj contents from ... Marcin 'Qrczak' Kowalczyk
- Re: Accessing ForeignObj contents f... Manuel M. T. Chakravarty
- RE: Accessing ForeignObj contents from Hask... Simon Marlow
- Re: Accessing ForeignObj contents from ... Keith Wansbrough
- Re: Accessing ForeignObj contents f... Marcin 'Qrczak' Kowalczyk
- Re: Accessing ForeignObj contents from ... Marcin 'Qrczak' Kowalczyk
- Re: Accessing ForeignObj contents f... Manuel M. T. Chakravarty
- Re: Accessing ForeignObj conten... Marcin 'Qrczak' Kowalczyk
- Re: Accessing ForeignObj c... Manuel M. T. Chakravarty
- RE: Accessing ForeignObj contents from ... Axel Simon
- Re: Accessing ForeignObj contents f... Marcin 'Qrczak' Kowalczyk
