1
mirror of https://github.com/XTLS/Xray-core.git synced 2025-12-13 05:14:17 +04:00

common/buf/multi_buffer.go: Fix Compact() (#5015)

Fixes https://github.com/XTLS/Xray-core/issues/5012

Co-authored-by: patterniha <71074308+patterniha@users.noreply.github.com>
This commit is contained in:
风扇滑翔翼
2025-08-15 23:27:12 +08:00
committed by GitHub
parent 5a8e9c25a4
commit f3cdcad541
3 changed files with 32 additions and 1 deletions

View File

@@ -244,6 +244,14 @@ func (b *Buffer) Cap() int32 {
return int32(len(b.v))
}
// Available returns the available capacity of the buffer content.
func (b *Buffer) Available() int32 {
if b == nil {
return 0
}
return int32(len(b.v)) - b.end
}
// IsEmpty returns true if the buffer is empty.
func (b *Buffer) IsEmpty() bool {
return b.Len() == 0