more leakchecking

This commit is contained in:
Booklordofthedings 2024-08-24 00:02:05 +02:00
parent 501a4af636
commit c0b09a47e6
6 changed files with 32 additions and 43 deletions

View file

@ -5,18 +5,8 @@ using System.Collections;
class Bofa class Bofa
{ {
private String __line = null; //The actual line
private String _line private String _line = null ~ if(_ != null) delete _; //The actual line
{
get
{
return __line;
}
set
{
__line = value;
}
}
private Bofa _lastObject = null; //If we are a container we keep track of the last container inside of us private Bofa _lastObject = null; //If we are a container we keep track of the last container inside of us
public StringView Name; public StringView Name;
@ -156,8 +146,6 @@ class Bofa
public ~this() public ~this()
{ {
if(_line != null)
delete _line;
if(Type == .Text) if(Type == .Text)
delete Value.Text; delete Value.Text;
else if(Type == .Object) else if(Type == .Object)

View file

@ -6,6 +6,7 @@ using System.Security.Cryptography;
using System.Collections; using System.Collections;
using Bofa.Parser; using Bofa.Parser;
using Bofa;
class BofaParser class BofaParser
{ {
@ -31,8 +32,7 @@ class BofaParser
int64 line = 1; int64 line = 1;
while (reader.Peek() case .Ok) //This might technically cause an issue when there is data added to the stream while we where busy processing, but if you hook this up to a network stream you deserve this happening to you while (reader.Peek() case .Ok) //This might technically cause an issue when there is data added to the stream while we where busy processing, but if you hook this up to a network stream you deserve this happening to you
{ {
String l = new .(); String l = new String();
if (reader.ReadLine(l) case .Err) if (reader.ReadLine(l) case .Err)
{ //Despite data being here, we cannot read it { //Despite data being here, we cannot read it
delete l; delete l;
@ -50,6 +50,8 @@ class BofaParser
} }
if (entry.Type == .Error) if (entry.Type == .Error)
{ {
if(entry.Data.Bofa != null)
delete entry.Data.Bofa;
pErrors.Add(line); pErrors.Add(line);
continue; continue;
} }
@ -193,19 +195,20 @@ class BofaParser
Bofa bofaRes = new Bofa(); Bofa bofaRes = new Bofa();
bofaRes.[Friend]_line = pLine; bofaRes.[Friend]_line = pLine;
bofaRes.Name = nameres.0; bofaRes.Name = nameres.0;
toReturn.Type = .Bofa;
toReturn.Data.Bofa = bofaRes;
bofaRes.Typename = typeName; bofaRes.Typename = typeName;
if (type.0 == "o") if (type.0 == "o")
{ {
bofaRes.Type = .Object; bofaRes.Type = .Object;
bofaRes.Value.Object = new .(); bofaRes.Value.Object = new .();
toReturn.Type = .Bofa;
toReturn.Data.Bofa = bofaRes;
return toReturn;
} }
else
{
bofaRes.Type = .Array; bofaRes.Type = .Array;
bofaRes.Value.Array = new .(); bofaRes.Value.Array = new .();
toReturn.Type = .Bofa; }
toReturn.Data.Bofa = bofaRes;
return toReturn; return toReturn;
} }
#endregion #endregion
@ -219,6 +222,11 @@ class BofaParser
Bofa bofaRes = new .(); Bofa bofaRes = new .();
bofaRes.Name = nameres.0; bofaRes.Name = nameres.0;
bofaRes.Typename = typeName; bofaRes.Typename = typeName;
toReturn.Data.Bofa = bofaRes;
bofaRes.[Friend]_line = pLine;
switch (type.0) switch (type.0)
{ {
case "n": case "n":
@ -226,7 +234,6 @@ class BofaParser
var result = float.Parse(line); var result = float.Parse(line);
if (result case .Err) if (result case .Err)
{ {
delete bofaRes;
toReturn.Type = .Error; toReturn.Type = .Error;
return toReturn; return toReturn;
} }
@ -238,7 +245,6 @@ class BofaParser
bofaRes.Value.Boolean = false; bofaRes.Value.Boolean = false;
else else
{ {
delete bofaRes;
toReturn.Type = .Error; toReturn.Type = .Error;
return toReturn; return toReturn;
} }
@ -251,7 +257,6 @@ class BofaParser
var result = double.Parse(line); var result = double.Parse(line);
if (result case .Err) if (result case .Err)
{ {
delete bofaRes;
toReturn.Type = .Error; toReturn.Type = .Error;
return toReturn; return toReturn;
} }
@ -261,7 +266,6 @@ class BofaParser
var result = int32.Parse(line); var result = int32.Parse(line);
if (result case .Err) if (result case .Err)
{ {
delete bofaRes;
toReturn.Type = .Error; toReturn.Type = .Error;
return toReturn; return toReturn;
} }
@ -271,7 +275,6 @@ class BofaParser
var result = int64.Parse(line); var result = int64.Parse(line);
if (result case .Err) if (result case .Err)
{ {
delete bofaRes;
toReturn.Type = .Error; toReturn.Type = .Error;
return toReturn; return toReturn;
} }
@ -283,15 +286,12 @@ class BofaParser
bofaRes.Value.Custom = line; bofaRes.Value.Custom = line;
bofaRes.Type = .Custom; bofaRes.Type = .Custom;
default: //Unknown type default: //Unknown type
delete bofaRes;
toReturn.Type = .Error; toReturn.Type = .Error;
return toReturn; return toReturn;
} }
#endregion #endregion
//If this ever returns something went wrong //If this ever returns something went wrong
bofaRes.[Friend]_line = pLine;
toReturn.Type = .Bofa; toReturn.Type = .Bofa;
toReturn.Data.Bofa = bofaRes;
return toReturn; return toReturn;
} }

View file

@ -22,7 +22,6 @@ extension Bofa
if(pToAdd.Type == .Text && target.Type == .Text) if(pToAdd.Type == .Text && target.Type == .Text)
{ {
target.Value.Text.Append(scope $"\n{pToAdd.Data.Text}"); target.Value.Text.Append(scope $"\n{pToAdd.Data.Text}");
//delete pToAdd.Data.Text;
return .Ok; return .Ok;
} }
else if(target.Type == .Object) else if(target.Type == .Object)

View file

@ -5,6 +5,6 @@ using System;
[Union] [Union]
struct ParserEntryUnion struct ParserEntryUnion
{ {
public Bofa Bofa; public Bofa Bofa = null;
public StringView Text; public StringView Text;
} }

View file

@ -8,7 +8,6 @@ class Program
public static void Main() public static void Main()
{ {
Bofa.Testing.Profiling.Profiling_Depth_Testing(); Bofa.Testing.Profiling.Profiling_Depth_Testing();
Bofa.Testing.Profiling.Profiling_Depth_Testing_Medium(); Bofa.Testing.Profiling.Profiling_Depth_Testing_Medium();
Bofa.Testing.Profiling.Profiling_Normal(); Bofa.Testing.Profiling.Profiling_Normal();
@ -16,5 +15,7 @@ class Program
Bofa.Testing.Profiling.Profiling_Normal_Large(); Bofa.Testing.Profiling.Profiling_Normal_Large();
Bofa.Testing.Profiling.Profiling_Texts(); Bofa.Testing.Profiling.Profiling_Texts();
Bofa.Testing.Profiling.Profiling_Texts_Large(); Bofa.Testing.Profiling.Profiling_Texts_Large();
Console.Read();
} }
} }

View file

@ -12,6 +12,7 @@ class Profiling
{ {
for (int i < 1000) for (int i < 1000)
{ {
String toParse = scope .(); String toParse = scope .();
toParse.Append(scope $""" toParse.Append(scope $"""
l one line of text l one line of text
@ -20,7 +21,7 @@ class Profiling
t text goes here t text goes here
- Text addendum - Text addendum
n tone 12.5 n tone 12.5
#husdhfiudshfds husdhfiudshfds
bn biggie 65645645645.6 bn biggie 65645645645.6
i int 234345 i int 234345
bi bint 38432847329847329 bi bint 38432847329847329