alignCheckedRead aligns the (read) position if necessary and suitable according to the specified alignment mask. alignCheckedRead returns an error if after any necessary alignment there isn't enough data left to be read into a value of the size corresponding to the specified alignment mask.
(m int)
| 270 | // if after any necessary alignment there isn't enough data left to be read into |
| 271 | // a value of the size corresponding to the specified alignment mask. |
| 272 | func (a *AlignedBuff) alignCheckedRead(m int) error { |
| 273 | a.pos = (a.pos + m) & ^m |
| 274 | if a.pos > len(a.data)-(m+1) { |
| 275 | return ErrEOF |
| 276 | } |
| 277 | return nil |
| 278 | } |
| 279 | |
| 280 | // alignWrite aligns the (write) position if necessary and suitable according to |
| 281 | // the specified alignment mask. It doubles as final payload padding helpmate in |