Skip to content
Snippets Groups Projects
Commit f4e69636 authored by Manuel Kieweg's avatar Manuel Kieweg
Browse files

fixed memory violation. stray nil dirs around tho

parent 00357cd1
No related branches found
No related tags found
3 merge requests!93Path traversal demo,!91"Overhaul Architecture",!90Develop
Pipeline #60728 passed with warnings
This commit is part of merge request !93. Comments created here will be created in the context of that merge request.
......@@ -11,6 +11,22 @@ type PathElement struct {
Name string
}
func (p *PathElement)Print() {
printPE(0, p)
}
func printPE(indent int, pe *PathElement) {
for i := 0; i < indent; i++ {
fmt.Print(" ")
}
fmt.Println(pe.Name)
if len(pe.Children) > 0 {
for _,p := range pe.Children {
printPE(indent+1, p)
}
}
}
func main() {
tree := schema.SchemaTree
paths := make(map[string]*PathElement)
......@@ -18,11 +34,12 @@ func main() {
for k,v := range tree {
if v.Parent != nil {
if v.Parent.Name == "device" {
paths[k] = processEntry(v)
pathElement := processEntry(v)
pathElement.Print()
paths[k] = pathElement
}
}
}
fmt.Println("stop")
}
func processEntry(e *yang.Entry) *PathElement {
......@@ -31,9 +48,10 @@ func processEntry(e *yang.Entry) *PathElement {
Children: make([]*PathElement, len(e.Dir)),
Name: e.Name,
}
i := 0
for _,v := range e.Dir {
child := processEntry(v)
elem.Children = append(elem.Children, child)
elem.Children[i] = processEntry(v)
i++
}
return elem
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment