Commit de0d5028 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 51d087af
...@@ -454,14 +454,16 @@ func (c *Client) Load(ctx context.Context, xid zodb.Xid) (data *zodb.Buf, serial ...@@ -454,14 +454,16 @@ func (c *Client) Load(ctx context.Context, xid zodb.Xid) (data *zodb.Buf, serial
//} //}
if resp.Compression { if resp.Compression {
// XXX cleanup mess vvv
data2 := zodb.BufAlloc(len(data.Data)) data2 := zodb.BufAlloc(len(data.Data))
data2.Data = data2.Data[:0] data2.Data = data2.Data[:0]
udata, err = decompress(resp.Data, data2) udata, err := decompress(data.Data, data2.Data)
data.Free() data.Free()
if err != nil { if err != nil {
data2.Free() data2.Free()
return nil, 0, fmt.Errorf("data corrupt: %v", err) return nil, 0, fmt.Errorf("data corrupt: %v", err)
} }
data2.Data = udata
data = data2 data = data2
} }
......
...@@ -926,11 +926,11 @@ func (d *decoder) genSlice1(assignto string, typ types.Type) { ...@@ -926,11 +926,11 @@ func (d *decoder) genSlice1(assignto string, typ types.Type) {
// emit code to size/encode/decode zodb.Buf // emit code to size/encode/decode zodb.Buf
// same as slice1 but buffer is allocated via zodb.BufAlloc // same as slice1 but buffer is allocated via zodb.BufAlloc
func (s *sizer) genBuf(path string) { func (s *sizer) genBuf(path string) {
s.genSlice1(path + ".Data", nil) // XXX typ unused s.genSlice1(path + ".Data", nil /* typ unused */)
} }
func (e *encoder) genBuf(path string) { func (e *encoder) genBuf(path string) {
e.genSlice1(path + ".Data", nil) // XXX typ unused e.genSlice1(path + ".Data", nil /* typ unused */)
} }
func (d *decoder) genBuf(path string) { func (d *decoder) genBuf(path string) {
...@@ -943,7 +943,7 @@ func (d *decoder) genBuf(path string) { ...@@ -943,7 +943,7 @@ func (d *decoder) genBuf(path string) {
d.overflow.AddExpr("l") d.overflow.AddExpr("l")
// TODO eventually do not copy but reference original // TODO eventually do not copy but reference original
d.emit("%v= zodb.BufAlloc(l)", path) d.emit("%v= zodb.BufAlloc(int(l))", path)
d.emit("copy(%v.Data, data[:l])", path) d.emit("copy(%v.Data, data[:l])", path)
d.emit("data = data[l:]") d.emit("data = data[l:]")
......
...@@ -1966,7 +1966,7 @@ func (p *AnswerObject) neoMsgDecode(data []byte) (int, error) { ...@@ -1966,7 +1966,7 @@ func (p *AnswerObject) neoMsgDecode(data []byte) (int, error) {
goto overflow goto overflow
} }
nread += 8 + l nread += 8 + l
p.Data = zodb.BufAlloc(l) p.Data = zodb.BufAlloc(int(l))
copy(p.Data.Data, data[:l]) copy(p.Data.Data, data[:l])
data = data[l:] data = data[l:]
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment