From: simonmar Date: Mon, 7 Nov 2005 16:39:04 +0000 (+0000) Subject: [project @ 2005-11-07 16:39:04 by simonmar] X-Git-Tag: Initial_conversion_from_CVS_complete~26 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=d968106fdef283b30d06ae45fa2f87329e1c2269;p=ghc-base.git [project @ 2005-11-07 16:39:04 by simonmar] add GHC notes to mallocForeignPtr --- diff --git a/GHC/ForeignPtr.hs b/GHC/ForeignPtr.hs index 9712763..c9217ef 100644 --- a/GHC/ForeignPtr.hs +++ b/GHC/ForeignPtr.hs @@ -121,6 +121,14 @@ mallocForeignPtr :: Storable a => IO (ForeignPtr a) -- although it may be implemented differently internally: you may not -- assume that the memory returned by 'mallocForeignPtr' has been -- allocated with 'Foreign.Marshal.Alloc.malloc'. +-- +-- GHC notes: 'mallocForeignPtr' has a heavily optimised +-- implementation in GHC. It uses pinned memory in the garbage +-- collected heap, so the 'ForeignPtr' does not require a finalizer to +-- free the memory. Use of 'mallocForeignPtr' and associated +-- functions is strongly recommended in preference to 'newForeignPtr' +-- with a finalizer. +-- mallocForeignPtr = doMalloc undefined where doMalloc :: Storable b => b -> IO (ForeignPtr b) doMalloc a = do