mirror of
https://github.com/jimeh/rbheap.git
synced 2026-02-19 12:56:46 +00:00
Break core structs down into obj and leak packages
This commit is contained in:
@@ -1,24 +1,28 @@
|
|||||||
package main
|
package leak
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
func NewLeakFinder(file1, file2, file3 string) *LeakFinder {
|
"github.com/jimeh/rbheapleak/obj"
|
||||||
return &LeakFinder{
|
)
|
||||||
|
|
||||||
|
func NewFinder(file1, file2, file3 string) *Finder {
|
||||||
|
return &Finder{
|
||||||
FilePaths: [3]string{file1, file2, file3},
|
FilePaths: [3]string{file1, file2, file3},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type LeakFinder struct {
|
type Finder struct {
|
||||||
FilePaths [3]string
|
FilePaths [3]string
|
||||||
Dumps [3]*Dump
|
Dumps [3]*obj.Dump
|
||||||
Leaks []*string
|
Leaks []*string
|
||||||
Verbose bool
|
Verbose bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *LeakFinder) Process() error {
|
func (s *Finder) Process() error {
|
||||||
for i, filePath := range s.FilePaths {
|
for i, filePath := range s.FilePaths {
|
||||||
s.log(fmt.Sprintf("Parsing %s", filePath))
|
s.log(fmt.Sprintf("Parsing %s", filePath))
|
||||||
dump := NewDump(filePath)
|
dump := obj.NewDump(filePath)
|
||||||
|
|
||||||
err := dump.Process()
|
err := dump.Process()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -32,17 +36,17 @@ func (s *LeakFinder) Process() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *LeakFinder) PrintLeakedAddresses() {
|
func (s *Finder) PrintLeakedAddresses() {
|
||||||
s.log("\nLeaked Addresses:")
|
s.log("\nLeaked Addresses:")
|
||||||
s.Dumps[1].PrintEntryAddress(s.FindLeaks())
|
s.Dumps[1].PrintEntryAddress(s.FindLeaks())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *LeakFinder) PrintLeakedObjects() {
|
func (s *Finder) PrintLeakedObjects() {
|
||||||
s.log("\nLeaked Objects:")
|
s.log("\nLeaked Objects:")
|
||||||
s.Dumps[1].PrintEntryJSON(s.FindLeaks())
|
s.Dumps[1].PrintEntryJSON(s.FindLeaks())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *LeakFinder) FindLeaks() []*string {
|
func (s *Finder) FindLeaks() []*string {
|
||||||
if s.Leaks != nil {
|
if s.Leaks != nil {
|
||||||
return s.Leaks
|
return s.Leaks
|
||||||
}
|
}
|
||||||
@@ -70,7 +74,7 @@ func (s *LeakFinder) FindLeaks() []*string {
|
|||||||
return s.Leaks
|
return s.Leaks
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *LeakFinder) log(msg string) {
|
func (s *Finder) log(msg string) {
|
||||||
if s.Verbose {
|
if s.Verbose {
|
||||||
fmt.Println(msg)
|
fmt.Println(msg)
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package main
|
package obj
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package main
|
package obj
|
||||||
|
|
||||||
func NewEntry(inputJSON []byte) (*Entry, error) {
|
func NewEntry(inputJSON []byte) (*Entry, error) {
|
||||||
obj, err := NewObject(inputJSON)
|
obj, err := NewObject(inputJSON)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package main
|
package obj
|
||||||
|
|
||||||
import "encoding/json"
|
import "encoding/json"
|
||||||
|
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.
|
// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.
|
||||||
|
|
||||||
package main
|
package obj
|
||||||
|
|
||||||
import (
|
import (
|
||||||
json "encoding/json"
|
json "encoding/json"
|
||||||
|
|
||||||
easyjson "github.com/mailru/easyjson"
|
easyjson "github.com/mailru/easyjson"
|
||||||
jlexer "github.com/mailru/easyjson/jlexer"
|
jlexer "github.com/mailru/easyjson/jlexer"
|
||||||
jwriter "github.com/mailru/easyjson/jwriter"
|
jwriter "github.com/mailru/easyjson/jwriter"
|
||||||
Reference in New Issue
Block a user