blob: 5fd27da0192d6a6ce71272cbfb03ec9eedf73f52 [file] [log] [blame]
Pragya Arya324337e2020-02-20 14:35:08 +05301package ndr
2
3import (
4 "fmt"
5 "reflect"
6)
7
8func (dec *Decoder) fillPipe(v reflect.Value, tag reflect.StructTag) error {
9 s, err := dec.readUint32() // read element count of first chunk
10 if err != nil {
11 return err
12 }
13 a := reflect.MakeSlice(v.Type(), 0, 0)
14 c := reflect.MakeSlice(v.Type(), int(s), int(s))
15 for s != 0 {
16 for i := 0; i < int(s); i++ {
17 err := dec.fill(c.Index(i), tag, &[]deferedPtr{})
18 if err != nil {
19 return fmt.Errorf("could not fill element %d of pipe: %v", i, err)
20 }
21 }
22 s, err = dec.readUint32() // read element count of first chunk
23 if err != nil {
24 return err
25 }
26 a = reflect.AppendSlice(a, c)
27 c = reflect.MakeSlice(v.Type(), int(s), int(s))
28 }
29 v.Set(a)
30 return nil
31}