mirror of
https://github.com/pgsty/minio.git
synced 2026-07-19 04:00:25 +03:00
erasure: Coding blocks during encoding were garbage, fixes #21
This commit is contained in:
+7
-3
@@ -181,18 +181,22 @@ func (e *Encoder) Encode(block []byte) ([][]byte, int) {
|
||||
pointers := make([]*byte, e.p.n)
|
||||
|
||||
var i int
|
||||
// Add data and code blocks to chunks
|
||||
for i = 0; i < e.p.n; i++ {
|
||||
// Add data blocks to chunks
|
||||
for i = 0; i < e.p.k; i++ {
|
||||
chunks[i] = block[i*chunk_size : (i+1)*chunk_size]
|
||||
pointers[i] = &chunks[i][0]
|
||||
}
|
||||
|
||||
for i = e.p.k; i < e.p.n; i++ {
|
||||
chunks[i] = make([]byte, chunk_size)
|
||||
pointers[i] = &chunks[i][0]
|
||||
}
|
||||
|
||||
data := (**C.uchar)(unsafe.Pointer(&pointers[:e.p.k][0]))
|
||||
coding := (**C.uchar)(unsafe.Pointer(&pointers[e.p.k:][0]))
|
||||
|
||||
C.ec_encode_data(C.int(chunk_size), e.k, e.m, e.encode_tbls, data,
|
||||
coding)
|
||||
|
||||
return chunks, block_len
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user