Author: wlux
Date: Sat Nov  1 18:47:23 2014
New Revision: 38145

URL: http://svn.gna.org/viewcvs/gnustep?rev=38145&view=rev
Log:
Fix a whole bunch of space leaks in StepTalk.

Modified:
    libs/steptalk/trunk/ChangeLog
    libs/steptalk/trunk/Frameworks/StepTalk/STClassInfo.m
    libs/steptalk/trunk/Frameworks/StepTalk/STContext.m
    libs/steptalk/trunk/Frameworks/StepTalk/STEnvironment.m
    libs/steptalk/trunk/Languages/Smalltalk/ChangeLog
    libs/steptalk/trunk/Languages/Smalltalk/STBlock.m
    libs/steptalk/trunk/Languages/Smalltalk/STBlockContext.m
    libs/steptalk/trunk/Languages/Smalltalk/STBytecodeInterpreter.m
    libs/steptalk/trunk/Languages/Smalltalk/STCompiledScript.m
    libs/steptalk/trunk/Languages/Smalltalk/STCompiler.m
    libs/steptalk/trunk/Languages/Smalltalk/STSmalltalkScriptObject.m
    libs/steptalk/trunk/Languages/Smalltalk/SmalltalkEngine.m

Modified: libs/steptalk/trunk/ChangeLog
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/steptalk/trunk/ChangeLog?rev=38145&r1=38144&r2=38145&view=diff
==============================================================================
--- libs/steptalk/trunk/ChangeLog       (original)
+++ libs/steptalk/trunk/ChangeLog       Sat Nov  1 18:47:23 2014
@@ -1,3 +1,10 @@
+2014-11-01  Wolfgang Lux  <[email protected]>
+
+       * Frameworks/StepTalk/STClassInfo.m (-dealloc): Release superclass
+       and superclassName attributes.
+       * Frameworks/StepTalk/STEnvironment.m (-initWithDescription:):
+       Remove duplicated RETAIN statement.
+
 2013-05-27  Wolfgang Lux  <[email protected]>
 
        * Frameworks/StepTalk/NSInvocation+additions.m

Modified: libs/steptalk/trunk/Frameworks/StepTalk/STClassInfo.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/steptalk/trunk/Frameworks/StepTalk/STClassInfo.m?rev=38145&r1=38144&r2=38145&view=diff
==============================================================================
--- libs/steptalk/trunk/Frameworks/StepTalk/STClassInfo.m       (original)
+++ libs/steptalk/trunk/Frameworks/StepTalk/STClassInfo.m       Sat Nov  1 
18:47:23 2014
@@ -48,6 +48,8 @@
 
 - (void)dealloc
 {
+    RELEASE(superclass);
+    RELEASE(superclassName);
     RELEASE(selectorCache);
     [super dealloc];
 }   

Modified: libs/steptalk/trunk/Frameworks/StepTalk/STContext.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/steptalk/trunk/Frameworks/StepTalk/STContext.m?rev=38145&r1=38144&r2=38145&view=diff
==============================================================================
--- libs/steptalk/trunk/Frameworks/StepTalk/STContext.m (original)
+++ libs/steptalk/trunk/Frameworks/StepTalk/STContext.m Sat Nov  1 18:47:23 2014
@@ -161,7 +161,7 @@
 }
 
 /**
-    Return object with name <var>objName</var>. If object is not found int the
+    Return object with name <var>objName</var>. If object is not found in the
     object dictionary, then object finders are used to try to find the object.
     If object is found by an object finder, then it is put into the object
     dicitonary. If there is no object with given name, <var>nil</var> is 

Modified: libs/steptalk/trunk/Frameworks/StepTalk/STEnvironment.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/steptalk/trunk/Frameworks/StepTalk/STEnvironment.m?rev=38145&r1=38144&r2=38145&view=diff
==============================================================================
--- libs/steptalk/trunk/Frameworks/StepTalk/STEnvironment.m     (original)
+++ libs/steptalk/trunk/Frameworks/StepTalk/STEnvironment.m     Sat Nov  1 
18:47:23 2014
@@ -116,7 +116,6 @@
         infoCache = [[NSMutableDictionary alloc] init];
 
         description = RETAIN(aDescription);
-        RETAIN(description);
         classes = [description classes];
 
         /* Load modules */
@@ -244,7 +243,7 @@
    ----------------------------------------------------------------------- */
 
 /**
-    Return object with name <var>objName</var>. If object is not found int the
+    Return object with name <var>objName</var>. If object is not found in the
     object dictionary, then object finders are used to try to find the object.
     If object is found by an object finder, then it is put into the object
     dicitonary. If there is no object with given name, <var>nil</var> is 

Modified: libs/steptalk/trunk/Languages/Smalltalk/ChangeLog
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/steptalk/trunk/Languages/Smalltalk/ChangeLog?rev=38145&r1=38144&r2=38145&view=diff
==============================================================================
--- libs/steptalk/trunk/Languages/Smalltalk/ChangeLog   (original)
+++ libs/steptalk/trunk/Languages/Smalltalk/ChangeLog   Sat Nov  1 18:47:23 2014
@@ -1,3 +1,22 @@
+2014-11-01  Wolfgang Lux  <[email protected]>
+
+    * STBlock.m (-dealloc): Release cachedContext attribute.
+    * STBlockContext.m (-dealloc): Restore method to release homeContext
+    attribute.
+    * STBytecodeInterpreter.m (-dealloc): Fix typo in method name and
+    release activeContext attribute.
+    * STBytecodeInterpreter.m (-interpretMethod:forReceiver:arguments:):
+    Release newContext also when an exception is raised while interpreting
+    the method.
+    * STCompiledScript.m (-executeInEnvironment:): Release script object
+    also when an exception is raised while interpreting the script.
+    * STCompiler.m (-dealloc): Release environment attribute.
+    * STCompiler.m (-compileString:): Release local auto release pool also
+    when an exception is raised during compilation.
+    * STSmalltalkScriptObject.m (-forwardInvocation:): Release local
+    autorelease pool and args array also when an exception is raised while
+    interpreting the method.
+
 2014-10-14  Wolfgang Lux  <[email protected]>
 
     * STBlockContext.h (STExecutionContext, -initWithInitialIP:stackSize:):

Modified: libs/steptalk/trunk/Languages/Smalltalk/STBlock.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/steptalk/trunk/Languages/Smalltalk/STBlock.m?rev=38145&r1=38144&r2=38145&view=diff
==============================================================================
--- libs/steptalk/trunk/Languages/Smalltalk/STBlock.m   (original)
+++ libs/steptalk/trunk/Languages/Smalltalk/STBlock.m   Sat Nov  1 18:47:23 2014
@@ -64,6 +64,7 @@
 {
     RELEASE(homeContext);
     RELEASE(interpreter);
+    RELEASE(cachedContext);
     [super dealloc];
 }
 - (NSUInteger)argumentCount

Modified: libs/steptalk/trunk/Languages/Smalltalk/STBlockContext.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/steptalk/trunk/Languages/Smalltalk/STBlockContext.m?rev=38145&r1=38144&r2=38145&view=diff
==============================================================================
--- libs/steptalk/trunk/Languages/Smalltalk/STBlockContext.m    (original)
+++ libs/steptalk/trunk/Languages/Smalltalk/STBlockContext.m    Sat Nov  1 
18:47:23 2014
@@ -45,6 +45,11 @@
         instructionPointer = initialIP;
     }
     return self; 
+}
+- (void)dealloc
+{
+    RELEASE(homeContext);
+    [super dealloc];
 }
 
 - (BOOL)isBlockContext

Modified: libs/steptalk/trunk/Languages/Smalltalk/STBytecodeInterpreter.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/steptalk/trunk/Languages/Smalltalk/STBytecodeInterpreter.m?rev=38145&r1=38144&r2=38145&view=diff
==============================================================================
--- libs/steptalk/trunk/Languages/Smalltalk/STBytecodeInterpreter.m     
(original)
+++ libs/steptalk/trunk/Languages/Smalltalk/STBytecodeInterpreter.m     Sat Nov 
 1 18:47:23 2014
@@ -97,9 +97,10 @@
         environment = RETAIN(env);
     return self;
 }
-- (void)delloc
+- (void)dealloc
 {
     RELEASE(environment);
+    RELEASE(activeContext);
     [super dealloc];
 }
 - (void)setEnvironment:(STEnvironment *)env
@@ -161,11 +162,13 @@
            }
            else
            {
+                RELEASE(newContext);
                [localException raise];
            }
        }
        else
        {
+            RELEASE(newContext);
            [localException raise];
        }
     NS_ENDHANDLER

Modified: libs/steptalk/trunk/Languages/Smalltalk/STCompiledScript.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/steptalk/trunk/Languages/Smalltalk/STCompiledScript.m?rev=38145&r1=38144&r2=38145&view=diff
==============================================================================
--- libs/steptalk/trunk/Languages/Smalltalk/STCompiledScript.m  (original)
+++ libs/steptalk/trunk/Languages/Smalltalk/STCompiledScript.m  Sat Nov  1 
18:47:23 2014
@@ -101,46 +101,56 @@
 
     methodCount = [methodDictionary count];
     
-    if(methodCount == 0)
+    if (methodCount == 0)
     {
         NSLog(@"Empty script executed");
     }
-    else if(methodCount == 1)
+    else if (methodCount == 1)
     {
         NSString *selName = [[methodDictionary allKeys] objectAtIndex:0];
         SEL       sel = STSelectorFromString(selName);
 
         NSDebugLog(@"Executing single-method script. (%@)", selName);
 
-        retval = [object performSelector:sel];
+        NS_DURING
+            retval = [object performSelector:sel];
+        NS_HANDLER
+            RELEASE(object);
+            [localException raise];
+        NS_ENDHANDLER
     }
-    else if(![object respondsToSelector:mainSelector])
+    else if (![object respondsToSelector:mainSelector])
     {
         NSLog(@"No 'main' method found");
     }
     else
     {
 
-        if( [object respondsToSelector:initializeSelector] )
-        {
-            NSDebugLog(@"Sending 'startUp' to script object");
-            [object performSelector:initializeSelector];
-        }
+        NS_DURING
+            if ([object respondsToSelector:initializeSelector])
+            {
+                NSDebugLog(@"Sending 'startUp' to script object");
+                [object performSelector:initializeSelector];
+            }
 
-        if( [object respondsToSelector:mainSelector] )
-        {
-            retval = [object performSelector:mainSelector];
-        }
-        else
-        {
-            NSLog(@"No 'main' found in script");
-        }
+            if ([object respondsToSelector:mainSelector])
+            {
+                retval = [object performSelector:mainSelector];
+            }
+            else
+            {
+                NSLog(@"No 'main' found in script");
+            }
 
-        if( [object respondsToSelector:finalizeSelector] )
-        {
-            NSDebugLog(@"Sending 'shutDown' to script object");
-            [object performSelector:finalizeSelector];
-        }
+            if ([object respondsToSelector:finalizeSelector])
+            {
+                NSDebugLog(@"Sending 'shutDown' to script object");
+                [object performSelector:finalizeSelector];
+            }
+        NS_HANDLER
+            RELEASE(object);
+            [localException raise];
+        NS_ENDHANDLER
     }
     
     RELEASE(object);

Modified: libs/steptalk/trunk/Languages/Smalltalk/STCompiler.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/steptalk/trunk/Languages/Smalltalk/STCompiler.m?rev=38145&r1=38144&r2=38145&view=diff
==============================================================================
--- libs/steptalk/trunk/Languages/Smalltalk/STCompiler.m        (original)
+++ libs/steptalk/trunk/Languages/Smalltalk/STCompiler.m        Sat Nov  1 
18:47:23 2014
@@ -150,6 +150,7 @@
 }
 - (void)dealloc
 {
+    RELEASE(environment);
     RELEASE(receiverVars);
     RELEASE(namedReferences);
     [super dealloc];
@@ -264,6 +265,7 @@
 
     if(!environment)
     {
+        [pool release];
         [NSException  raise:STCompilerGenericException
                      format:@"Compilation environment is not initialized"];
         return nil;
@@ -286,24 +288,29 @@
         {
             NSString *tokenString;
             NSInteger line;
-            
-            tokenString = [reader tokenString];
+
+            tokenString = RETAIN([reader tokenString]);
             line = [reader currentLine];
-            
+
             RELEASE(reader);
             reader = nil;
+
+            RETAIN(localException);
+            [pool release];
 
             [NSException  raise:STCompilerSyntaxException
                          format:exceptionFmt,
                                 (long)line,
-                                tokenString,
-                                [localException reason]];
+                                AUTORELEASE(tokenString),
+                                [AUTORELEASE(localException) reason]];
                          
         }
         RELEASE(reader);
         reader = nil;
 
-        [localException raise];
+        RETAIN(localException);
+        [pool release];
+        [AUTORELEASE(localException) raise];
     }
     NS_ENDHANDLER
 

Modified: libs/steptalk/trunk/Languages/Smalltalk/STSmalltalkScriptObject.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/steptalk/trunk/Languages/Smalltalk/STSmalltalkScriptObject.m?rev=38145&r1=38144&r2=38145&view=diff
==============================================================================
--- libs/steptalk/trunk/Languages/Smalltalk/STSmalltalkScriptObject.m   
(original)
+++ libs/steptalk/trunk/Languages/Smalltalk/STSmalltalkScriptObject.m   Sat Nov 
 1 18:47:23 2014
@@ -196,11 +196,18 @@
     // NSDebugLLog(@"STSending",
     //            @">> forwarding to self ...");
 
-    retval = [interpreter interpretMethod:method 
-                              forReceiver:self
-                                arguments:args];
-    RELEASE(args);
-    
+    NS_DURING
+        retval = [interpreter interpretMethod:method 
+                                  forReceiver:self
+                                    arguments:args];
+        RELEASE(args);
+    NS_HANDLER
+        RETAIN(localException);
+        RELEASE(args);
+        [pool release];
+        [AUTORELEASE(localException) raise];
+    NS_ENDHANDLER
+
     // NSDebugLLog(@"STSending",
     //            @"<< returned from forwarding");
 

Modified: libs/steptalk/trunk/Languages/Smalltalk/SmalltalkEngine.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/steptalk/trunk/Languages/Smalltalk/SmalltalkEngine.m?rev=38145&r1=38144&r2=38145&view=diff
==============================================================================
--- libs/steptalk/trunk/Languages/Smalltalk/SmalltalkEngine.m   (original)
+++ libs/steptalk/trunk/Languages/Smalltalk/SmalltalkEngine.m   Sat Nov  1 
18:47:23 2014
@@ -78,14 +78,10 @@
     STCompiledScript      *compiledScript;
     id                     retval = nil;
 
-    compiler = [[STCompiler alloc] init];
-
-    [compiler setEnvironment:context];
+    compiler = [STCompiler compilerWithEnvironment:context];
 
     compiledScript = [compiler compileString:script];
     retval = [compiledScript executeInEnvironment:context];
-
-    AUTORELEASE(compiler);
 
     return retval;
 }


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to