Commits

ppavel committed 2912e56

Fixed device array allocation for clGetDeviceIDs

Comments (0)

Files changed (1)

System/OpenCL/Raw/V10/DeviceInfo.hs

 
 foreign import ccall "clGetDeviceIDs" raw_clGetDeviceIDs :: PlatformID -> CLbitfield -> CLuint -> Ptr DeviceID -> Ptr CLuint -> IO CLint
 clGetDeviceIDs :: PlatformID -> DeviceType -> CLuint -> IO (Either ErrorCode [DeviceID])
-clGetDeviceIDs platform (DeviceType device_type) num_entries = alloca $ \(devices::Ptr DeviceID) -> alloca $ \(num_devices::Ptr CLuint) -> do
+clGetDeviceIDs platform (DeviceType device_type) num_entries = allocaArray (fromIntegral num_entries) $ \(devices::Ptr DeviceID) -> alloca $ \(num_devices::Ptr CLuint) -> do
   errcode <- ErrorCode <$> raw_clGetDeviceIDs platform device_type num_entries devices num_devices
   if errcode == clSuccess
       then Right <$> (peek num_devices >>= \num_devicesN -> peekArray (fromIntegral num_devicesN) devices)