compiler/libec; ide/CodeEditor: Fixed compiler leak on initDeclarators invoking Proce...
authorJerome St-Louis <jerome@ecere.com>
Thu, 16 Feb 2012 09:27:30 +0000 (16:27 +0700)
committerJerome St-Louis <jerome@ecere.com>
Thu, 16 Feb 2012 09:27:30 +0000 (16:27 +0700)
compiler/libec/src/pass0.ec
ide/src/designer/CodeEditor.ec

index 7b960d6..eefe3bc 100644 (file)
@@ -748,6 +748,7 @@ static void ProcessClass(ClassType classType, OldList definitions, Symbol symbol
       {
          // We need a struct
          OldList * specs = MkList(), * declarators = (initDeclarators != null) ? initDeclarators : MkList();
+         initDeclarators = null;
 
          /*
          structName[0] = 0;
@@ -764,7 +765,7 @@ static void ProcessClass(ClassType classType, OldList definitions, Symbol symbol
          // TOFIX : Fix this...
          symbol.structExternal = external;
 
-         external.declaration = MkDeclaration(specs, declarators /*initDeclarators*/);
+         external.declaration = MkDeclaration(specs, declarators);
          after = external;
       
          symbol.declaredStruct = true;
@@ -1476,6 +1477,9 @@ static void ProcessClass(ClassType classType, OldList definitions, Symbol symbol
          }
       }
    }
+
+   if(initDeclarators != null)
+      FreeList(initDeclarators, FreeInitDeclarator);
 }
 
 public void PreProcessClassDefinitions()
@@ -1514,8 +1518,17 @@ public void PreProcessClassDefinitions()
                         Symbol symbol = FindClass(specifier.id.string);
                         if(symbol)
                         {
-                           ProcessClass((specifier.type == unionSpecifier) ? unionClass : normalClass, specifier.definitions, symbol, specifier.baseSpecs, specifier.list, specifier.loc, ast, external.prev, declaration.declarators);
-                           declaration.declarators = null;
+                           OldList * initDeclarators = null;
+                           if(inCompiler)
+                           {
+                              // Give the declarators away to ProcessClass
+                              // It will include the declarators in the class if appropriate, otherwise free them
+                              initDeclarators = declaration.declarators;
+                              declaration.declarators = null;
+                           }
+                           ProcessClass((specifier.type == unionSpecifier) ? unionClass : normalClass, specifier.definitions,
+                              symbol, specifier.baseSpecs, specifier.list, specifier.loc, ast, external.prev,
+                              initDeclarators);
                         }
                      }
                   }
index ab276f3..a380f0c 100644 (file)
@@ -2795,9 +2795,15 @@ class CodeEditor : Window
          }
       }
       if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
+      {
          SetDefaultDeclMode(privateAccess);
+         SetDeclMode(privateAccess);
+      }
       else
+      {
          SetDefaultDeclMode(defaultAccess);
+         SetDeclMode(defaultAccess);
+      }
 
       StripExtension(mainModuleName);
       module = ImportedModule { name = CopyString(mainModuleName), type = moduleDefinition };