Commit 72bc3bf4 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 45129ef4
...@@ -32,6 +32,7 @@ import ( ...@@ -32,6 +32,7 @@ import (
"../../../../storage/fs1" "../../../../storage/fs1"
"../../../../xcommon/xfmt" "../../../../xcommon/xfmt"
"../../../../xcommon/xslice"
) )
...@@ -103,13 +104,7 @@ func fsTail(w io.Writer, path string, ntxn int) (err error) { ...@@ -103,13 +104,7 @@ func fsTail(w io.Writer, path string, ntxn int) (err error) {
// read raw data inside transaction record // read raw data inside transaction record
dataLen := txnh.DataLen() dataLen := txnh.DataLen()
if int64(cap(data)) < dataLen { data = xslice.Realloc64(data, dataLen)
// TODO -> CeilPow2
data = make([]byte, dataLen)
} else {
data = data[:dataLen]
}
_, err = fSeq.ReadAt(data, txnh.DataPos()) _, err = fSeq.ReadAt(data, txnh.DataPos())
if err != nil { if err != nil {
// XXX -> txnh.Err(...) ? // XXX -> txnh.Err(...) ?
......
...@@ -38,7 +38,12 @@ func Resize(b []byte, n int) []byte { ...@@ -38,7 +38,12 @@ func Resize(b []byte, n int) []byte {
// The memory for all elements becomes uninitialized. // The memory for all elements becomes uninitialized.
// XXX semantic clash with C realloc(3) ? or it does not matter? // XXX semantic clash with C realloc(3) ? or it does not matter?
func Realloc(b []byte, n int) []byte { func Realloc(b []byte, n int) []byte {
if cap(b) >= n { return Realloc64(b, int64(n))
}
// Realloc64 is the same as Realloc but for size typed as int64
func Realloc64(b []byte, n int64) []byte {
if int64(cap(b)) >= n {
return b[:n] return b[:n]
} }
......
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