diff --git a/leak_finder.go b/leak/finder.go similarity index 69% rename from leak_finder.go rename to leak/finder.go index f7a61b6..47f39a9 100644 --- a/leak_finder.go +++ b/leak/finder.go @@ -1,24 +1,28 @@ -package main +package leak -import "fmt" +import ( + "fmt" -func NewLeakFinder(file1, file2, file3 string) *LeakFinder { - return &LeakFinder{ + "github.com/jimeh/rbheapleak/obj" +) + +func NewFinder(file1, file2, file3 string) *Finder { + return &Finder{ FilePaths: [3]string{file1, file2, file3}, } } -type LeakFinder struct { +type Finder struct { FilePaths [3]string - Dumps [3]*Dump + Dumps [3]*obj.Dump Leaks []*string Verbose bool } -func (s *LeakFinder) Process() error { +func (s *Finder) Process() error { for i, filePath := range s.FilePaths { s.log(fmt.Sprintf("Parsing %s", filePath)) - dump := NewDump(filePath) + dump := obj.NewDump(filePath) err := dump.Process() if err != nil { @@ -32,17 +36,17 @@ func (s *LeakFinder) Process() error { return nil } -func (s *LeakFinder) PrintLeakedAddresses() { +func (s *Finder) PrintLeakedAddresses() { s.log("\nLeaked Addresses:") s.Dumps[1].PrintEntryAddress(s.FindLeaks()) } -func (s *LeakFinder) PrintLeakedObjects() { +func (s *Finder) PrintLeakedObjects() { s.log("\nLeaked Objects:") s.Dumps[1].PrintEntryJSON(s.FindLeaks()) } -func (s *LeakFinder) FindLeaks() []*string { +func (s *Finder) FindLeaks() []*string { if s.Leaks != nil { return s.Leaks } @@ -70,7 +74,7 @@ func (s *LeakFinder) FindLeaks() []*string { return s.Leaks } -func (s *LeakFinder) log(msg string) { +func (s *Finder) log(msg string) { if s.Verbose { fmt.Println(msg) } diff --git a/dump.go b/obj/dump.go similarity index 99% rename from dump.go rename to obj/dump.go index 70caffa..d16d01c 100644 --- a/dump.go +++ b/obj/dump.go @@ -1,4 +1,4 @@ -package main +package obj import ( "bufio" diff --git a/entry.go b/obj/entry.go similarity index 96% rename from entry.go rename to obj/entry.go index cafeb28..aba3886 100644 --- a/entry.go +++ b/obj/entry.go @@ -1,4 +1,4 @@ -package main +package obj func NewEntry(inputJSON []byte) (*Entry, error) { obj, err := NewObject(inputJSON) diff --git a/object.go b/obj/object.go similarity index 96% rename from object.go rename to obj/object.go index 3da23d2..675c04c 100644 --- a/object.go +++ b/obj/object.go @@ -1,4 +1,4 @@ -package main +package obj import "encoding/json" diff --git a/object_easyjson.go b/obj/object_easyjson.go similarity index 99% rename from object_easyjson.go rename to obj/object_easyjson.go index 27605d1..c939380 100644 --- a/object_easyjson.go +++ b/obj/object_easyjson.go @@ -1,9 +1,10 @@ // Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT. -package main +package obj import ( json "encoding/json" + easyjson "github.com/mailru/easyjson" jlexer "github.com/mailru/easyjson/jlexer" jwriter "github.com/mailru/easyjson/jwriter"