Update comments across the codebase

This commit is contained in:
Harshavardhana
2015-03-03 02:36:12 -08:00
parent 137584d658
commit 3a3c8645fc
24 changed files with 198 additions and 346 deletions

View File

@@ -23,6 +23,9 @@ import (
var castanagoliTable = crc32.MakeTable(crc32.Castagnoli)
/// Convenience functions
// Single caller crc helper
func Sum32(buffer []byte) uint32 {
crc := crc32.New(castanagoliTable)
crc.Reset()
@@ -30,6 +33,7 @@ func Sum32(buffer []byte) uint32 {
return crc.Sum32()
}
// Low memory footprint io.Reader based crc helper
func Sum(reader io.Reader) (uint32, error) {
h := New()
var err error

View File

@@ -26,17 +26,22 @@ func New() hash.Hash32 {
return &digest{crc: 0}
}
// Return size of crc
func (d *digest) Size() int { return Size }
// Stub
func (d *digest) BlockSize() int { return 1 }
// Get crc in bytes
func (d *digest) Sum(in []byte) []byte {
s := d.crc
return append(in, byte(s>>24), byte(s>>16), byte(s>>8), byte(s))
}
// Return current crc in digest object
func (d *digest) Sum32() uint32 { return d.crc }
// Reset default crc
func (d *digest) Reset() { d.crc = 0 }
// Update returns the result of adding the bytes in p to the crc.
@@ -44,13 +49,15 @@ func (d *digest) update(crc uint32, p []byte) uint32 {
return updateCastanagoliPCL(crc, p)
}
// Write data
func (d *digest) Write(p []byte) (n int, err error) {
d.crc = d.update(d.crc, p)
return len(p), nil
}
// Convenience functions
/// Convenience functions
// Single caller crc helper
func Sum32(data []byte) uint32 {
crc32 := New()
crc32.Reset()
@@ -58,6 +65,7 @@ func Sum32(data []byte) uint32 {
return crc32.Sum32()
}
// Low memory footprint io.Reader based crc helper
func Sum(reader io.Reader) (uint32, error) {
h := New()
var err error