packages feed

VulkanMemoryAllocator 0.6 → 0.6.0.1

raw patch · 5 files changed

+57/−58 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

VulkanMemoryAllocator.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           VulkanMemoryAllocator-version:        0.6+version:        0.6.0.1 synopsis:       Bindings to the VulkanMemoryAllocator library category:       Graphics homepage:       https://github.com/expipiplus1/vulkan#readme
VulkanMemoryAllocator/include/vk_mem_alloc.h view
@@ -5217,9 +5217,14 @@     }
 
     typedef T* iterator;
+    typedef const T* const_iterator;
 
     iterator begin() { return m_pArray; }
     iterator end() { return m_pArray + m_Count; }
+    const_iterator cbegin() const { return m_pArray; }
+    const_iterator cend() const { return m_pArray + m_Count; }
+    const_iterator begin() const { return cbegin(); }
+    const_iterator end() const { return cend(); }
 
 private:
     AllocatorT m_Allocator;
@@ -6040,6 +6045,9 @@ 
     const_iterator cbegin() const { return const_iterator(&m_RawList, m_RawList.Front()); }
     const_iterator cend() const { return const_iterator(&m_RawList, VMA_NULL); }
+    
+    const_iterator begin() const { return cbegin(); }
+    const_iterator end() const { return cend(); }
 
     void clear() { m_RawList.Clear(); }
     void push_back(const T& value) { m_RawList.PushBack(value); }
@@ -9377,12 +9385,8 @@     // True if previous visited suballocation was free.
     bool prevFree = false;
 
-    for(VmaSuballocationList::const_iterator suballocItem = m_Suballocations.cbegin();
-        suballocItem != m_Suballocations.cend();
-        ++suballocItem)
+    for(const auto& subAlloc : m_Suballocations)
     {
-        const VmaSuballocation& subAlloc = *suballocItem;
-
         // Actual offset of this suballocation doesn't match expected one.
         VMA_VALIDATE(subAlloc.offset == calculatedOffset);
 
@@ -9476,11 +9480,8 @@     outInfo.unusedRangeSizeMin = UINT64_MAX;
     outInfo.unusedRangeSizeMax = 0;
 
-    for(VmaSuballocationList::const_iterator suballocItem = m_Suballocations.cbegin();
-        suballocItem != m_Suballocations.cend();
-        ++suballocItem)
+    for(const auto& suballoc : m_Suballocations)
     {
-        const VmaSuballocation& suballoc = *suballocItem;
         if(suballoc.type != VMA_SUBALLOCATION_TYPE_FREE)
         {
             outInfo.allocationSizeMin = VMA_MIN(outInfo.allocationSizeMin, suballoc.size);
@@ -9515,17 +9516,15 @@         m_FreeCount); // unusedRangeCount
 
     size_t i = 0;
-    for(VmaSuballocationList::const_iterator suballocItem = m_Suballocations.cbegin();
-        suballocItem != m_Suballocations.cend();
-        ++suballocItem, ++i)
+    for(const auto& suballoc : m_Suballocations)
     {
-        if(suballocItem->type == VMA_SUBALLOCATION_TYPE_FREE)
+        if(suballoc.type == VMA_SUBALLOCATION_TYPE_FREE)
         {
-            PrintDetailedMap_UnusedRange(json, suballocItem->offset, suballocItem->size);
+            PrintDetailedMap_UnusedRange(json, suballoc.offset, suballoc.size);
         }
         else
         {
-            PrintDetailedMap_Allocation(json, suballocItem->offset, suballocItem->hAllocation);
+            PrintDetailedMap_Allocation(json, suballoc.offset, suballoc.hAllocation);
         }
     }
 
@@ -9750,18 +9749,16 @@ 
 VkResult VmaBlockMetadata_Generic::CheckCorruption(const void* pBlockData)
 {
-    for(VmaSuballocationList::iterator it = m_Suballocations.begin();
-        it != m_Suballocations.end();
-        ++it)
+    for(auto& suballoc : m_Suballocations)
     {
-        if(it->type != VMA_SUBALLOCATION_TYPE_FREE)
+        if(suballoc.type != VMA_SUBALLOCATION_TYPE_FREE)
         {
-            if(!VmaValidateMagicValue(pBlockData, it->offset - VMA_DEBUG_MARGIN))
+            if(!VmaValidateMagicValue(pBlockData, suballoc.offset - VMA_DEBUG_MARGIN))
             {
                 VMA_ASSERT(0 && "MEMORY CORRUPTION DETECTED BEFORE VALIDATED ALLOCATION!");
                 return VK_ERROR_VALIDATION_FAILED_EXT;
             }
-            if(!VmaValidateMagicValue(pBlockData, it->offset + it->size))
+            if(!VmaValidateMagicValue(pBlockData, suballoc.offset + suballoc.size))
             {
                 VMA_ASSERT(0 && "MEMORY CORRUPTION DETECTED AFTER VALIDATED ALLOCATION!");
                 return VK_ERROR_VALIDATION_FAILED_EXT;
@@ -10295,14 +10292,12 @@ 
     VkDeviceSize minAlignment = VK_WHOLE_SIZE;
     bool typeConflictFound = false;
-    for(VmaSuballocationList::const_iterator it = m_Suballocations.cbegin();
-        it != m_Suballocations.cend();
-        ++it)
+    for(const auto& suballoc : m_Suballocations)
     {
-        const VmaSuballocationType suballocType = it->type;
+        const VmaSuballocationType suballocType = suballoc.type;
         if(suballocType != VMA_SUBALLOCATION_TYPE_FREE)
         {
-            minAlignment = VMA_MIN(minAlignment, it->hAllocation->GetAlignment());
+            minAlignment = VMA_MIN(minAlignment, suballoc.hAllocation->GetAlignment());
             if(VmaIsBufferImageGranularityConflict(inOutPrevSuballocType, suballocType))
             {
                 typeConflictFound = true;
changelog.md view
@@ -2,6 +2,10 @@  ## WIP +## [0.6.0.1] - 2021-06-26+- Bump VMA, no functional change+- Use allocaBytes over allocaBytesAligned where possible+ ## [0.6] - 2021-06-22 - Bump VMA, adding alignment info to PoolCreateInfo 
package.yaml view
@@ -1,5 +1,5 @@ name: VulkanMemoryAllocator-version: "0.6"+version: "0.6.0.1" synopsis: Bindings to the VulkanMemoryAllocator library category: Graphics maintainer: Joe Hermaszewski <live.long.and.prosper@monoid.al>
src/VulkanMemoryAllocator.hs view
@@ -183,7 +183,7 @@ import Control.Exception.Base (bracket) import Control.Monad (unless) import Control.Monad.IO.Class (liftIO)-import Foreign.Marshal.Alloc (allocaBytesAligned)+import Foreign.Marshal.Alloc (allocaBytes) import Foreign.Marshal.Alloc (callocBytes) import Foreign.Marshal.Alloc (free) import Foreign.Marshal.Utils (maybePeek)@@ -1013,9 +1013,9 @@                        ("createInfo" ::: Vector AllocationCreateInfo)                     -> io (("allocations" ::: Vector Allocation), ("allocationInfo" ::: Vector AllocationInfo)) allocateMemoryPages allocator vkMemoryRequirements createInfo = liftIO . evalContT $ do-  pPVkMemoryRequirements <- ContT $ allocaBytesAligned @MemoryRequirements ((Data.Vector.length (vkMemoryRequirements)) * 24) 8+  pPVkMemoryRequirements <- ContT $ allocaBytes @MemoryRequirements ((Data.Vector.length (vkMemoryRequirements)) * 24)   Data.Vector.imapM_ (\i e -> ContT $ pokeCStruct (pPVkMemoryRequirements `plusPtr` (24 * (i)) :: Ptr MemoryRequirements) (e) . ($ ())) (vkMemoryRequirements)-  pPCreateInfo <- ContT $ allocaBytesAligned @AllocationCreateInfo ((Data.Vector.length (createInfo)) * 48) 8+  pPCreateInfo <- ContT $ allocaBytes @AllocationCreateInfo ((Data.Vector.length (createInfo)) * 48)   lift $ Data.Vector.imapM_ (\i e -> poke (pPCreateInfo `plusPtr` (48 * (i)) :: Ptr AllocationCreateInfo) (e)) (createInfo)   let pVkMemoryRequirementsLength = Data.Vector.length $ (vkMemoryRequirements)   lift $ unless ((Data.Vector.length $ (createInfo)) == pVkMemoryRequirementsLength) $@@ -1186,7 +1186,7 @@                    ("allocations" ::: Vector Allocation)                 -> io () freeMemoryPages allocator allocations = liftIO . evalContT $ do-  pPAllocations <- ContT $ allocaBytesAligned @Allocation ((Data.Vector.length (allocations)) * 8) 8+  pPAllocations <- ContT $ allocaBytes @Allocation ((Data.Vector.length (allocations)) * 8)   lift $ Data.Vector.imapM_ (\i e -> poke (pPAllocations `plusPtr` (8 * (i)) :: Ptr Allocation) (e)) (allocations)   lift $ traceAroundEvent "vmaFreeMemoryPages" ((ffiVmaFreeMemoryPages) (allocator) ((fromIntegral (Data.Vector.length $ (allocations)) :: CSize)) (pPAllocations))   pure $ ()@@ -1603,18 +1603,18 @@   let sizesLength = Data.Vector.length $ (sizes)   lift $ unless (fromIntegral sizesLength == allocationsLength || sizesLength == 0) $     throwIO $ IOError Nothing InvalidArgument "" "sizes and allocations must have the same length" Nothing Nothing-  pAllocations <- ContT $ allocaBytesAligned @Allocation ((Data.Vector.length (allocations)) * 8) 8+  pAllocations <- ContT $ allocaBytes @Allocation ((Data.Vector.length (allocations)) * 8)   lift $ Data.Vector.imapM_ (\i e -> poke (pAllocations `plusPtr` (8 * (i)) :: Ptr Allocation) (e)) (allocations)   offsets' <- if Data.Vector.null (offsets)     then pure nullPtr     else do-      pOffsets <- ContT $ allocaBytesAligned @DeviceSize (((Data.Vector.length (offsets))) * 8) 8+      pOffsets <- ContT $ allocaBytes @DeviceSize (((Data.Vector.length (offsets))) * 8)       lift $ Data.Vector.imapM_ (\i e -> poke (pOffsets `plusPtr` (8 * (i)) :: Ptr DeviceSize) (e)) ((offsets))       pure $ pOffsets   sizes' <- if Data.Vector.null (sizes)     then pure nullPtr     else do-      pSizes <- ContT $ allocaBytesAligned @DeviceSize (((Data.Vector.length (sizes))) * 8) 8+      pSizes <- ContT $ allocaBytes @DeviceSize (((Data.Vector.length (sizes))) * 8)       lift $ Data.Vector.imapM_ (\i e -> poke (pSizes `plusPtr` (8 * (i)) :: Ptr DeviceSize) (e)) ((sizes))       pure $ pSizes   r <- lift $ traceAroundEvent "vmaFlushAllocations" ((ffiVmaFlushAllocations) (allocator) ((fromIntegral allocationsLength :: Word32)) (pAllocations) offsets' sizes')@@ -1675,18 +1675,18 @@   let sizesLength = Data.Vector.length $ (sizes)   lift $ unless (fromIntegral sizesLength == allocationsLength || sizesLength == 0) $     throwIO $ IOError Nothing InvalidArgument "" "sizes and allocations must have the same length" Nothing Nothing-  pAllocations <- ContT $ allocaBytesAligned @Allocation ((Data.Vector.length (allocations)) * 8) 8+  pAllocations <- ContT $ allocaBytes @Allocation ((Data.Vector.length (allocations)) * 8)   lift $ Data.Vector.imapM_ (\i e -> poke (pAllocations `plusPtr` (8 * (i)) :: Ptr Allocation) (e)) (allocations)   offsets' <- if Data.Vector.null (offsets)     then pure nullPtr     else do-      pOffsets <- ContT $ allocaBytesAligned @DeviceSize (((Data.Vector.length (offsets))) * 8) 8+      pOffsets <- ContT $ allocaBytes @DeviceSize (((Data.Vector.length (offsets))) * 8)       lift $ Data.Vector.imapM_ (\i e -> poke (pOffsets `plusPtr` (8 * (i)) :: Ptr DeviceSize) (e)) ((offsets))       pure $ pOffsets   sizes' <- if Data.Vector.null (sizes)     then pure nullPtr     else do-      pSizes <- ContT $ allocaBytesAligned @DeviceSize (((Data.Vector.length (sizes))) * 8) 8+      pSizes <- ContT $ allocaBytes @DeviceSize (((Data.Vector.length (sizes))) * 8)       lift $ Data.Vector.imapM_ (\i e -> poke (pSizes `plusPtr` (8 * (i)) :: Ptr DeviceSize) (e)) ((sizes))       pure $ pSizes   r <- lift $ traceAroundEvent "vmaInvalidateAllocations" ((ffiVmaInvalidateAllocations) (allocator) ((fromIntegral allocationsLength :: Word32)) (pAllocations) offsets' sizes')@@ -1998,7 +1998,7 @@               ("defragmentationInfo" ::: Maybe DefragmentationInfo)            -> io (("allocationsChanged" ::: Vector Bool), DefragmentationStats) defragment allocator allocations defragmentationInfo = liftIO . evalContT $ do-  pPAllocations <- ContT $ allocaBytesAligned @Allocation ((Data.Vector.length (allocations)) * 8) 8+  pPAllocations <- ContT $ allocaBytes @Allocation ((Data.Vector.length (allocations)) * 8)   lift $ Data.Vector.imapM_ (\i e -> poke (pPAllocations `plusPtr` (8 * (i)) :: Ptr Allocation) (e)) (allocations)   pPAllocationsChanged <- ContT $ bracket (callocBytes @Bool32 ((fromIntegral ((fromIntegral (Data.Vector.length $ (allocations)) :: CSize))) * 4)) free   pDefragmentationInfo <- case (defragmentationInfo) of@@ -2524,7 +2524,7 @@ deriving instance Show DeviceMemoryCallbacks  instance ToCStruct DeviceMemoryCallbacks where-  withCStruct x f = allocaBytesAligned 24 8 $ \p -> pokeCStruct p x (f p)+  withCStruct x f = allocaBytes 24 $ \p -> pokeCStruct p x (f p)   pokeCStruct p DeviceMemoryCallbacks{..} f = do     poke ((p `plusPtr` 0 :: Ptr PFN_vmaAllocateDeviceMemoryFunction)) (pfnAllocate)     poke ((p `plusPtr` 8 :: Ptr PFN_vmaFreeDeviceMemoryFunction)) (pfnFree)@@ -2781,7 +2781,7 @@ deriving instance Show VulkanFunctions  instance ToCStruct VulkanFunctions where-  withCStruct x f = allocaBytesAligned 176 8 $ \p -> pokeCStruct p x (f p)+  withCStruct x f = allocaBytes 176 $ \p -> pokeCStruct p x (f p)   pokeCStruct p VulkanFunctions{..} f = do     poke ((p `plusPtr` 0 :: Ptr PFN_vkGetPhysicalDeviceProperties)) (vkGetPhysicalDeviceProperties)     poke ((p `plusPtr` 8 :: Ptr PFN_vkGetPhysicalDeviceMemoryProperties)) (vkGetPhysicalDeviceMemoryProperties)@@ -2923,7 +2923,7 @@ deriving instance Show RecordSettings  instance ToCStruct RecordSettings where-  withCStruct x f = allocaBytesAligned 16 8 $ \p -> pokeCStruct p x (f p)+  withCStruct x f = allocaBytes 16 $ \p -> pokeCStruct p x (f p)   pokeCStruct p RecordSettings{..} f = evalContT $ do     lift $ poke ((p `plusPtr` 0 :: Ptr RecordFlags)) (flags)     pFilePath'' <- ContT $ useAsCString (filePath)@@ -3060,7 +3060,7 @@ deriving instance Show AllocatorCreateInfo  instance ToCStruct AllocatorCreateInfo where-  withCStruct x f = allocaBytesAligned 96 8 $ \p -> pokeCStruct p x (f p)+  withCStruct x f = allocaBytes 96 $ \p -> pokeCStruct p x (f p)   pokeCStruct p AllocatorCreateInfo{..} f = evalContT $ do     lift $ poke ((p `plusPtr` 0 :: Ptr AllocatorCreateFlags)) (flags)     lift $ poke ((p `plusPtr` 8 :: Ptr (Ptr PhysicalDevice_T))) (physicalDevice)@@ -3163,7 +3163,7 @@ deriving instance Show AllocatorInfo  instance ToCStruct AllocatorInfo where-  withCStruct x f = allocaBytesAligned 24 8 $ \p -> pokeCStruct p x (f p)+  withCStruct x f = allocaBytes 24 $ \p -> pokeCStruct p x (f p)   pokeCStruct p AllocatorInfo{..} f = do     poke ((p `plusPtr` 0 :: Ptr (Ptr Instance_T))) (instance')     poke ((p `plusPtr` 8 :: Ptr (Ptr PhysicalDevice_T))) (physicalDevice)@@ -3232,7 +3232,7 @@ deriving instance Show StatInfo  instance ToCStruct StatInfo where-  withCStruct x f = allocaBytesAligned 80 8 $ \p -> pokeCStruct p x (f p)+  withCStruct x f = allocaBytes 80 $ \p -> pokeCStruct p x (f p)   pokeCStruct p StatInfo{..} f = do     poke ((p `plusPtr` 0 :: Ptr Word32)) (blockCount)     poke ((p `plusPtr` 4 :: Ptr Word32)) (allocationCount)@@ -3339,7 +3339,7 @@ deriving instance Show Stats  instance ToCStruct Stats where-  withCStruct x f = allocaBytesAligned 3920 8 $ \p -> pokeCStruct p x (f p)+  withCStruct x f = allocaBytes 3920 $ \p -> pokeCStruct p x (f p)   pokeCStruct p Stats{..} f = do     unless ((Data.Vector.length $ (memoryType)) <= MAX_MEMORY_TYPES) $       throwIO $ IOError Nothing InvalidArgument "" "memoryType is too long, a maximum of MAX_MEMORY_TYPES elements are allowed" Nothing Nothing@@ -3421,7 +3421,7 @@ deriving instance Show Budget  instance ToCStruct Budget where-  withCStruct x f = allocaBytesAligned 32 8 $ \p -> pokeCStruct p x (f p)+  withCStruct x f = allocaBytes 32 $ \p -> pokeCStruct p x (f p)   pokeCStruct p Budget{..} f = do     poke ((p `plusPtr` 0 :: Ptr DeviceSize)) (blockBytes)     poke ((p `plusPtr` 8 :: Ptr DeviceSize)) (allocationBytes)@@ -3799,7 +3799,7 @@ deriving instance Show AllocationCreateInfo  instance ToCStruct AllocationCreateInfo where-  withCStruct x f = allocaBytesAligned 48 8 $ \p -> pokeCStruct p x (f p)+  withCStruct x f = allocaBytes 48 $ \p -> pokeCStruct p x (f p)   pokeCStruct p AllocationCreateInfo{..} f = do     poke ((p `plusPtr` 0 :: Ptr AllocationCreateFlags)) (flags)     poke ((p `plusPtr` 4 :: Ptr MemoryUsage)) (usage)@@ -4017,7 +4017,7 @@ deriving instance Show PoolCreateInfo  instance ToCStruct PoolCreateInfo where-  withCStruct x f = allocaBytesAligned 56 8 $ \p -> pokeCStruct p x (f p)+  withCStruct x f = allocaBytes 56 $ \p -> pokeCStruct p x (f p)   pokeCStruct p PoolCreateInfo{..} f = do     poke ((p `plusPtr` 0 :: Ptr Word32)) (memoryTypeIndex)     poke ((p `plusPtr` 4 :: Ptr PoolCreateFlags)) (flags)@@ -4107,7 +4107,7 @@ deriving instance Show PoolStats  instance ToCStruct PoolStats where-  withCStruct x f = allocaBytesAligned 48 8 $ \p -> pokeCStruct p x (f p)+  withCStruct x f = allocaBytes 48 $ \p -> pokeCStruct p x (f p)   pokeCStruct p PoolStats{..} f = do     poke ((p `plusPtr` 0 :: Ptr DeviceSize)) (size)     poke ((p `plusPtr` 8 :: Ptr DeviceSize)) (unusedSize)@@ -4252,7 +4252,7 @@ deriving instance Show AllocationInfo  instance ToCStruct AllocationInfo where-  withCStruct x f = allocaBytesAligned 48 8 $ \p -> pokeCStruct p x (f p)+  withCStruct x f = allocaBytes 48 $ \p -> pokeCStruct p x (f p)   pokeCStruct p AllocationInfo{..} f = do     poke ((p `plusPtr` 0 :: Ptr Word32)) (memoryType)     poke ((p `plusPtr` 8 :: Ptr DeviceMemory)) (deviceMemory)@@ -4422,16 +4422,16 @@ deriving instance Show DefragmentationInfo2  instance ToCStruct DefragmentationInfo2 where-  withCStruct x f = allocaBytesAligned 80 8 $ \p -> pokeCStruct p x (f p)+  withCStruct x f = allocaBytes 80 $ \p -> pokeCStruct p x (f p)   pokeCStruct p DefragmentationInfo2{..} f = evalContT $ do     lift $ poke ((p `plusPtr` 0 :: Ptr DefragmentationFlags)) (flags)     lift $ poke ((p `plusPtr` 4 :: Ptr Word32)) ((fromIntegral (Data.Vector.length $ (allocations)) :: Word32))-    pPAllocations' <- ContT $ allocaBytesAligned @Allocation ((Data.Vector.length (allocations)) * 8) 8+    pPAllocations' <- ContT $ allocaBytes @Allocation ((Data.Vector.length (allocations)) * 8)     lift $ Data.Vector.imapM_ (\i e -> poke (pPAllocations' `plusPtr` (8 * (i)) :: Ptr Allocation) (e)) (allocations)     lift $ poke ((p `plusPtr` 8 :: Ptr (Ptr Allocation))) (pPAllocations')     lift $ poke ((p `plusPtr` 16 :: Ptr (Ptr Bool32))) (allocationsChanged)     lift $ poke ((p `plusPtr` 24 :: Ptr Word32)) ((fromIntegral (Data.Vector.length $ (pools)) :: Word32))-    pPPools' <- ContT $ allocaBytesAligned @Pool ((Data.Vector.length (pools)) * 8) 8+    pPPools' <- ContT $ allocaBytes @Pool ((Data.Vector.length (pools)) * 8)     lift $ Data.Vector.imapM_ (\i e -> poke (pPPools' `plusPtr` (8 * (i)) :: Ptr Pool) (e)) (pools)     lift $ poke ((p `plusPtr` 32 :: Ptr (Ptr Pool))) (pPPools')     lift $ poke ((p `plusPtr` 40 :: Ptr DeviceSize)) (maxCpuBytesToMove)@@ -4497,7 +4497,7 @@ deriving instance Show DefragmentationPassMoveInfo  instance ToCStruct DefragmentationPassMoveInfo where-  withCStruct x f = allocaBytesAligned 24 8 $ \p -> pokeCStruct p x (f p)+  withCStruct x f = allocaBytes 24 $ \p -> pokeCStruct p x (f p)   pokeCStruct p DefragmentationPassMoveInfo{..} f = do     poke ((p `plusPtr` 0 :: Ptr Allocation)) (allocation)     poke ((p `plusPtr` 8 :: Ptr DeviceMemory)) (memory)@@ -4550,7 +4550,7 @@ deriving instance Show DefragmentationPassInfo  instance ToCStruct DefragmentationPassInfo where-  withCStruct x f = allocaBytesAligned 16 8 $ \p -> pokeCStruct p x (f p)+  withCStruct x f = allocaBytes 16 $ \p -> pokeCStruct p x (f p)   pokeCStruct p DefragmentationPassInfo{..} f = do     poke ((p `plusPtr` 0 :: Ptr Word32)) (moveCount)     poke ((p `plusPtr` 8 :: Ptr (Ptr DefragmentationPassMoveInfo))) (moves)@@ -4608,7 +4608,7 @@ deriving instance Show DefragmentationInfo  instance ToCStruct DefragmentationInfo where-  withCStruct x f = allocaBytesAligned 16 8 $ \p -> pokeCStruct p x (f p)+  withCStruct x f = allocaBytes 16 $ \p -> pokeCStruct p x (f p)   pokeCStruct p DefragmentationInfo{..} f = do     poke ((p `plusPtr` 0 :: Ptr DeviceSize)) (maxBytesToMove)     poke ((p `plusPtr` 8 :: Ptr Word32)) (maxAllocationsToMove)@@ -4662,7 +4662,7 @@ deriving instance Show DefragmentationStats  instance ToCStruct DefragmentationStats where-  withCStruct x f = allocaBytesAligned 24 8 $ \p -> pokeCStruct p x (f p)+  withCStruct x f = allocaBytes 24 $ \p -> pokeCStruct p x (f p)   pokeCStruct p DefragmentationStats{..} f = do     poke ((p `plusPtr` 0 :: Ptr DeviceSize)) (bytesMoved)     poke ((p `plusPtr` 8 :: Ptr DeviceSize)) (bytesFreed)