-- | Utilities for dealing with `GArray` types.
module Data.GI.Base.GArray
  ( allocGArray
  ) where

import Foreign.C (CInt(..), CUInt(..))
import Foreign.Ptr (Ptr)

import Data.GI.Base.BasicTypes (GArray(..))

-- | Args are zero_terminated, clear_, element_size
foreign import ccall g_array_new :: CInt -> CInt -> CUInt -> IO (Ptr (GArray a))

-- | Allocate a `GArray` with elements of the given size.
allocGArray :: CUInt -> IO (Ptr (GArray a))
allocGArray :: forall a. CUInt -> IO (Ptr (GArray a))
allocGArray CUInt
size = CInt -> CInt -> CUInt -> IO (Ptr (GArray a))
forall a. CInt -> CInt -> CUInt -> IO (Ptr (GArray a))
g_array_new CInt
0 CInt
1 CUInt
size