module Nes.Memory.Internal (callocForeignPtr) where

import Foreign
import Nes.Memory (MemoryPointer)

callocForeignPtr :: Int -> IO MemoryPointer
callocForeignPtr :: Int -> IO MemoryPointer
callocForeignPtr Int
size = do
    Ptr ()
ptr <- Int -> IO (Ptr ())
forall a. Int -> IO (Ptr a)
callocBytes Int
size
    FinalizerPtr () -> Ptr () -> IO MemoryPointer
forall a. FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)
newForeignPtr FinalizerPtr ()
forall a. FinalizerPtr a
finalizerFree Ptr ()
ptr