summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/slang-generate/main.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/tools/slang-generate/main.cpp b/tools/slang-generate/main.cpp
index 5fca7c21a..700c1bb21 100644
--- a/tools/slang-generate/main.cpp
+++ b/tools/slang-generate/main.cpp
@@ -30,18 +30,33 @@ struct Node
StringSpan span;
// The body of this node for other flavors
- Node* body;
+ Node* body = nullptr;
// The next node in the document
- Node* next;
+ Node* next = nullptr;
+
+ Node() = default;
+ ~Node()
+ {
+ if (body) delete body;
+ if (next) delete next;
+ }
};
// Information about a source file
-struct SourceFile
+struct SourceFile : public RefObject
{
String inputPath;
- StringSpan text;
- Node* node;
+ StringSpan text;
+ Node* node = nullptr;
+ SourceFile() = default;
+ ~SourceFile()
+ {
+ if (text.begin())
+ free((void*)text.begin());
+ if (node)
+ delete node;
+ }
};
void addNode(
@@ -795,10 +810,12 @@ SourceFile* parseSourceFile(const String& path)
Node* node = parseSourceFile(sourceFile);
sourceFile->node = node;
+
+ fclose(inputStream);
return sourceFile;
}
-List<SourceFile*> gSourceFiles;
+List<RefPtr<SourceFile>> gSourceFiles;
int main(
int argc,