Browse Source

Fixed unfreed memory. Still 2 blocks to be freed.

lainz 11 years ago
parent
commit
0c8113a59e
2 changed files with 15 additions and 6 deletions
  1. 10 6
      bgrascript.pas
  2. 5 0
      test/test_bgrascript/test_bgrascript.lpi

+ 10 - 6
bgrascript.pas

@@ -1,7 +1,7 @@
 unit BGRAScript;
 unit BGRAScript;
 
 
 {$mode objfpc}{$H+}
 {$mode objfpc}{$H+}
-{$define debug}
+{ $define debug}
 
 
 interface
 interface
 
 
@@ -11,8 +11,9 @@ uses
 {Template}
 {Template}
 procedure SynCompletionList(itemlist: TStrings);
 procedure SynCompletionList(itemlist: TStrings);
 {Scripting}
 {Scripting}
-function ScriptCommand(command: string; bitmap: TBGRABitmap; variables: TStringList): boolean;
-function ScriptCommandList(commandlist: TStrings; bitmap: TBGRABitmap): boolean;
+function ScriptCommand(command: string; var bitmap: TBGRABitmap;
+  var variables: TStringList): boolean;
+function ScriptCommandList(commandlist: TStrings; var bitmap: TBGRABitmap): boolean;
 
 
 {Tools}
 {Tools}
 function StrToDrawMode(mode: string): TDrawMode;
 function StrToDrawMode(mode: string): TDrawMode;
@@ -83,7 +84,8 @@ begin
   end;
   end;
 end;
 end;
 
 
-function ScriptCommand(command: string; bitmap: TBGRABitmap; variables: TStringList): boolean;
+function ScriptCommand(command: string; var bitmap: TBGRABitmap;
+  var variables: TStringList): boolean;
 
 
   function ParamCheck(passed, mustbe: integer): boolean;
   function ParamCheck(passed, mustbe: integer): boolean;
   begin
   begin
@@ -116,7 +118,7 @@ begin
   passed := list.Count;
   passed := list.Count;
 
 
   {Replace values in variable names}
   {Replace values in variable names}
-  for i:=0 to list.Count -1 do
+  for i := 0 to list.Count - 1 do
     if variables.Values[list[i]] <> '' then
     if variables.Values[list[i]] <> '' then
       list[i] := variables.Values[list[i]];
       list[i] := variables.Values[list[i]];
 
 
@@ -562,9 +564,11 @@ begin
     writeln(' ' + list[i]);
     writeln(' ' + list[i]);
   writeln('____________________');
   writeln('____________________');
   {$endif}
   {$endif}
+
+  list.Free;
 end;
 end;
 
 
-function ScriptCommandList(commandlist: TStrings; bitmap: TBGRABitmap): boolean;
+function ScriptCommandList(commandlist: TStrings; var bitmap: TBGRABitmap): boolean;
 var
 var
   i: integer;
   i: integer;
   variables: TStringList;
   variables: TStringList;

+ 5 - 0
test/test_bgrascript/test_bgrascript.lpi

@@ -48,6 +48,11 @@
               <UseHeaptrc Value="True"/>
               <UseHeaptrc Value="True"/>
               <UseExternalDbgSyms Value="True"/>
               <UseExternalDbgSyms Value="True"/>
             </Debugging>
             </Debugging>
+            <Options>
+              <Win32>
+                <GraphicApplication Value="True"/>
+              </Win32>
+            </Options>
           </Linking>
           </Linking>
           <Other>
           <Other>
             <CompilerMessages>
             <CompilerMessages>