From 3c4f76ed4674a7fc3891a73ded42b1ff47fb94a7 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Thu, 19 Mar 2009 18:18:17 +0000 Subject: [PATCH] Fixed the memory leaks arising from not clearing mobiles before an input --- backends/GenerateC.hs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/backends/GenerateC.hs b/backends/GenerateC.hs index df11e4d..1860487 100644 --- a/backends/GenerateC.hs +++ b/backends/GenerateC.hs @@ -1076,7 +1076,8 @@ cgenInputItem c (A.InVariable m v) rhs tell [");"] A.Mobile {} -> - do tell ["MTChanIn(wptr,"] + do call genClearMobile m v -- TODO insert this via a pass + tell ["MTChanIn(wptr,"] call genVariable c tell [",(void*)"] rhs @@ -1299,12 +1300,7 @@ cdeclareInit _ _ _ = Nothing -- | Free a declared item that's going out of scope. cdeclareFree :: Meta -> A.Type -> A.Variable -> Maybe (CGen ()) -cdeclareFree _ (A.Mobile {}) v = Just $ - do tell ["if ("] - call genVariable v - tell ["!=NULL){MTRelease(wptr,(void*)"] - call genVariable v - tell [");}"] +cdeclareFree m (A.Mobile {}) v = Just $ call genClearMobile m v cdeclareFree _ _ _ = Nothing {- @@ -1928,7 +1924,7 @@ cgenClearMobile :: Meta -> A.Variable -> CGen () cgenClearMobile _ v = do tell ["if("] genVar - tell ["!=NULL){MTRelease("] + tell ["!=NULL){MTRelease(wptr,(void*)"] genVar tell [");"] genVar