[project @ 2003-04-08 16:02:05 by simonpj]
[ghc-base.git] / GHC / ForeignPtr.hs
index dad5f04..cefc899 100644 (file)
@@ -21,7 +21,6 @@ module GHC.ForeignPtr
        mallocForeignPtrBytes,
        addForeignPtrFinalizer, 
        touchForeignPtr,
-       withForeignPtr,
        foreignPtrToPtr,
        castForeignPtr,
        newConcForeignPtr,
@@ -210,31 +209,6 @@ touchForeignPtr (ForeignPtr fo r)
 touchForeignPtr (MallocPtr fo r)
    = IO $ \s -> case touch# fo s of s -> (# s, () #)
 
-withForeignPtr :: ForeignPtr a -> (Ptr a -> IO b) -> IO b
--- ^This is a way to look at the pointer living inside a
--- foreign object.  This function takes a function which is
--- applied to that pointer. The resulting 'IO' action is then
--- executed. The foreign object is kept alive at least during
--- the whole action, even if it is not used directly
--- inside. Note that it is not safe to return the pointer from
--- the action and use it after the action completes. All uses
--- of the pointer should be inside the
--- 'withForeignPtr' bracket.  The reason for
--- this unsafety is the same as for
--- 'foreignPtrToPtr' below: the finalizer
--- may run earlier than expected, because the compiler can only
--- track usage of the 'ForeignPtr' object, not
--- a 'Ptr' object made from it.
---
--- This function is normally used for marshalling data to
--- or from the object pointed to by the
--- 'ForeignPtr', using the operations from the
--- 'Storable' class.
-withForeignPtr fo io
-  = do r <- io (foreignPtrToPtr fo)
-       touchForeignPtr fo
-       return r
-
 foreignPtrToPtr :: ForeignPtr a -> Ptr a
 -- ^This function extracts the pointer component of a foreign
 -- pointer.  This is a potentially dangerous operations, as if the