From 7a9ef992afa96ed177ae9a4a67d302017ab73852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Wed, 5 Apr 2023 22:03:43 +0200 Subject: Fix non-exhaustive pattern match warnings --- src/ICE.chs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/ICE.chs') diff --git a/src/ICE.chs b/src/ICE.chs index 06ad7aa..98584a2 100644 --- a/src/ICE.chs +++ b/src/ICE.chs @@ -131,13 +131,19 @@ iceCreate role cb = do {#fun ice_destroy as ^ { isStrans `IceSession' } -> `()' #} iceRemoteInfo :: IceSession -> IO IceRemoteInfo -iceRemoteInfo sess = - allocaBytes (32*128) $ \bytes -> - allocaArray 29 $ \carr -> do - let (ufrag : pass : def : cptrs) = take 32 $ iterate (`plusPtr` 128) bytes - pokeArray carr cptrs - - ncand <- {#call ice_encode_session #} (isStrans sess) ufrag pass def carr 128 29 +iceRemoteInfo sess = do + let maxlen = 128 + maxcand = 29 + + allocaBytes maxlen $ \ufrag -> + allocaBytes maxlen $ \pass -> + allocaBytes maxlen $ \def -> + allocaBytes (maxcand*maxlen) $ \bytes -> + allocaArray maxcand $ \carr -> do + let cptrs = take maxcand $ iterate (`plusPtr` maxlen) bytes + pokeArray carr $ take maxcand cptrs + + ncand <- {#call ice_encode_session #} (isStrans sess) ufrag pass def carr (fromIntegral maxlen) (fromIntegral maxcand) if ncand < 0 then fail "failed to generate ICE remote info" else IceRemoteInfo <$> (T.pack <$> peekCString ufrag) -- cgit v1.2.3