packages feed

missing-foreign 0.1.0 → 0.1.1

raw patch · 3 files changed

+62/−62 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Foreign.Marshal.Alloc.Calloc: calloc :: Storable a => IO (Ptr a)
- Foreign.Marshal.Alloc.Calloc: callocBytes :: Int -> IO (Ptr a)
+ Foreign.Marshal.MissingAlloc: calloc :: Storable a => IO (Ptr a)
+ Foreign.Marshal.MissingAlloc: callocBytes :: Int -> IO (Ptr a)

Files

− Foreign/Marshal/Alloc/Calloc.hs
@@ -1,60 +0,0 @@-{-# LANGUAGE ForeignFunctionInterface #-}-------------------------------------------------------------------- |--- Module       : Foreign.Marshal.Alloc.Calloc--- Copyright    : (c) Jason Dagit 2011--- License      : BSD-style (see the file LICENSE)--- --- Maintainer   : dagitj@gmail.com------ The module "Foreign.Marshal.Alloc.Calloc" provides access to--- the 'calloc' (e.g., allocated 0-initialized chunks of memory--- outside of the Haskell storage manager).------ If any of these allocation functions fails, an exception is--- raised.------ The storage allocated is alligned to store any basic--- foreign types.---------------------------------------------------------------------module Foreign.Marshal.Alloc.Calloc (-  -- * Memory allocation-  -- ** Initialized dynamic allocation-  calloc,     -- :: Storable a => IO (Ptr a)-  callocBytes -- :: Int -> IO (Ptr a)-) where--import Foreign.C.Types-import Foreign.Storable-import Foreign.Ptr-import Foreign.Marshal.Error--foreign import ccall unsafe "stdlib.h calloc"-  _calloc :: CSize -> CSize -> IO (Ptr a)---- | Allocate a block of memory that is sufficient to hold values of type--- @a@.  The size of the area allocated is determined by the 'sizeOf'--- method from the instance of 'Storable' for the appropriate type.--- The memory is initalized to 0.------ The memory may be deallocated using 'free' or 'finalizerFree' when--- no longer required.----{-# INLINE calloc #-}-calloc :: Storable a => IO (Ptr a)-calloc = doCalloc undefined-  where-  doCalloc       :: Storable b => b -> IO (Ptr b)-  doCalloc dummy = callocBytes (sizeOf dummy)---- | Allocate a block of memory of the given number of bytes.--- The block of memory is sufficiently aligned for any of the basic--- foreign tyes that fit into a memory block of the allocated size.--- The memory is initialized to 0.------ The memory may be deallocated using 'free' or 'finalizerFree' when--- no longer required.----callocBytes :: Int -> IO (Ptr a)-callocBytes size = throwIfNull "calloc" (_calloc (fromIntegral size) 1)
+ Foreign/Marshal/MissingAlloc.hs view
@@ -0,0 +1,60 @@+{-# LANGUAGE ForeignFunctionInterface #-}+----------------------------------------------------------------+-- |+-- Module       : Foreign.Marshal.MissingAlloc+-- Copyright    : (c) Jason Dagit 2011+-- License      : BSD-style (see the file LICENSE)+-- +-- Maintainer   : dagitj@gmail.com+--+-- The module "Foreign.Marshal.MissingAlloc" provides access to+-- 'calloc' (e.g., allocated 0-initialized chunks of memory+-- outside of the Haskell storage manager).+--+-- If any of these allocation functions fails, an exception is+-- raised.+--+-- The storage allocated is alligned to store any basic+-- foreign types.+--+----------------------------------------------------------------+module Foreign.Marshal.MissingAlloc (+  -- * Memory allocation+  -- ** Initialized dynamic allocation+  calloc,     -- :: Storable a => IO (Ptr a)+  callocBytes -- :: Int -> IO (Ptr a)+) where++import Foreign.C.Types+import Foreign.Storable+import Foreign.Ptr+import Foreign.Marshal.Error++foreign import ccall unsafe "stdlib.h calloc"+  _calloc :: CSize -> CSize -> IO (Ptr a)++-- | Allocate a block of memory that is sufficient to hold values of type+-- @a@.  The size of the area allocated is determined by the 'sizeOf'+-- method from the instance of 'Storable' for the appropriate type.+-- The memory is initalized to 0.+--+-- The memory may be deallocated using 'free' or 'finalizerFree' when+-- no longer required.+--+{-# INLINE calloc #-}+calloc :: Storable a => IO (Ptr a)+calloc = doCalloc undefined+  where+  doCalloc       :: Storable b => b -> IO (Ptr b)+  doCalloc dummy = callocBytes (sizeOf dummy)++-- | Allocate a block of memory of the given number of bytes.+-- The block of memory is sufficiently aligned for any of the basic+-- foreign tyes that fit into a memory block of the allocated size.+-- The memory is initialized to 0.+--+-- The memory may be deallocated using 'free' or 'finalizerFree' when+-- no longer required.+--+callocBytes :: Int -> IO (Ptr a)+callocBytes size = throwIfNull "calloc" (_calloc (fromIntegral size) 1)
missing-foreign.cabal view
@@ -1,5 +1,5 @@ Name:                missing-foreign-Version:             0.1.0+Version:             0.1.1 Synopsis:            Convenience functions for FFI work Description:         Add several functions missing in the standard                      Foreign modules:@@ -17,7 +17,7 @@  Library   -- Modules exported by the library.-  Exposed-modules:     Foreign.Marshal.Alloc.Calloc+  Exposed-modules:     Foreign.Marshal.MissingAlloc                        Foreign.Marshal.MissingUtils      -- Packages needed in order to build this package.