]> Cypherpunks repositories - gostls13.git/commitdiff
hash: update documentation for MakeTable in crc32 and crc64
authorJoe Tsai <joetsai@digital-static.net>
Thu, 3 Sep 2015 22:24:53 +0000 (15:24 -0700)
committerIan Lance Taylor <iant@golang.org>
Fri, 4 Sep 2015 02:16:27 +0000 (02:16 +0000)
Explicitly say that *Table returned by MakeTable may not be
modified. Otherwise, this leads to very subtle bugs that may
or may not manifest themselves.

Same comment was made on package crc64, to keep the future
open to the caching tables that crc32 effectively does.

Fixes: #12487.
Change-Id: I2881bebb8b16f6f8564412172774c79c2593c6c1
Reviewed-on: https://go-review.googlesource.com/14258
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/hash/crc32/crc32.go
src/hash/crc64/crc64.go

index 234d92968902d9003fdad3db899c3f3b35c8e367..228cc0461ca1e2cae39bb325f1aa5c8259d19ee5 100644 (file)
@@ -61,7 +61,8 @@ type slicing8Table [8]Table
 var iEEETable8 *slicing8Table
 var iEEETable8Once sync.Once
 
-// MakeTable returns the Table constructed from the specified polynomial.
+// MakeTable returns a Table constructed from the specified polynomial.
+// The contents of this Table must not be modified.
 func MakeTable(poly uint32) *Table {
        switch poly {
        case IEEE:
index 692586798848cbfe6dad7cb386b3fad20ca238e8..b420a2256223e01c75bbc74e0778c73b037227c9 100644 (file)
@@ -24,7 +24,8 @@ const (
 // Table is a 256-word table representing the polynomial for efficient processing.
 type Table [256]uint64
 
-// MakeTable returns the Table constructed from the specified polynomial.
+// MakeTable returns a Table constructed from the specified polynomial.
+// The contents of this Table must not be modified.
 func MakeTable(poly uint64) *Table {
        t := new(Table)
        for i := 0; i < 256; i++ {