 memset2D ptr (width,height) pitch symbol = nothingIfOk `fmap` cudaMemset2D ptr pitch symbol width height
 
 {# fun unsafe cudaMemset2D
-    { withDevicePtr* `DevicePtr' ,
-      cIntConv       `Int64'     ,
-                     `Int'       ,
-      cIntConv       `Int64'     ,
-      cIntConv       `Int64'     } -> `Status' cToEnum #}
+    { withDevicePtr* `DevicePtr ()' ,
+      cIntConv       `Int64'        ,
+                     `Int'          ,
+      cIntConv       `Int64'        ,
+      cIntConv       `Int64'        } -> `Status' cToEnum #}
 
 
 -- |
 -- Initialise the elements of a 3D array to a given value
 --
-memset3D :: DevicePtr                   -- ^ The device memory
+memset3D :: DevicePtr ()                -- ^ The device memory
          -> (Int64,Int64,Int64)         -- ^ The (width,height,depth) of the array in bytes
          -> Int64                       -- ^ The allocation pitch, as returned by 'malloc3D'
          -> Int                         -- ^ Value to set for each byte

-- Allocate the specified number of bytes in linear memory on the device. The
-- memory is suitably aligned for any kind of variable, and is not cleared.
--
malloc       :: Int64 -> IO (Either String DevicePtr)
malloc bytes = do
    (rv,ptr) <- cudaMalloc bytes
    case rv of
        Success -> doAutoRelease free_ >>= \fp ->
                   newDevicePtr fp ptr >>= (return.Right)
        _       -> return.Left $ describe rv

{# fun unsafe cudaMalloc

-- |
-- A reference to data stored on the device. It is automatically freed.
--
type DevicePtr a = ForeignPtr a

withDevicePtr :: DevicePtr a -> (Ptr a -> IO b) -> IO b
withDevicePtr =  withForeignPtr

newDevicePtr   :: Ptr () -> IO (DevicePtr ())
newDevicePtr p =  (doAutoRelease free_) >>= \f -> newForeignPtr f p

--
-- Memory copy
