From b3d13508fbb05cc7b7330e0f23d35ac7e2a73244 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Fri, 24 Jul 2015 14:11:03 +1000 Subject: [PATCH] Renamed to OutMessage. --- internal/buffer/out_message.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/buffer/out_message.go b/internal/buffer/out_message.go index fe69a79..123a141e 100644 --- a/internal/buffer/out_message.go +++ b/internal/buffer/out_message.go @@ -21,25 +21,25 @@ import ( "github.com/jacobsa/fuse/internal/fusekernel" ) -// Buffer provides a mechanism for constructing a single contiguous fuse +// OutMessage provides a mechanism for constructing a single contiguous fuse // message from multiple segments, where the first segment is always a // fusekernel.OutHeader message. // // Must be created with New. Exception: the zero value has Bytes() == nil. -type Buffer struct { +type OutMessage struct { slice []byte } // Create a new buffer whose initial contents are a zeroed fusekernel.OutHeader // message, and with room enough to grow by extra bytes. -func New(extra uintptr) (b Buffer) { +func NewOutMessage(extra uintptr) (b OutMessage) { const headerSize = unsafe.Sizeof(fusekernel.OutHeader{}) b.slice = make([]byte, headerSize, headerSize+extra) return } // Return a pointer to the header at the start of the buffer. -func (b *Buffer) OutHeader() (h *fusekernel.OutHeader) { +func (b *OutMessage) OutHeader() (h *fusekernel.OutHeader) { sh := (*reflect.SliceHeader)(unsafe.Pointer(&b.slice)) h = (*fusekernel.OutHeader)(unsafe.Pointer(sh.Data)) return @@ -48,7 +48,7 @@ func (b *Buffer) OutHeader() (h *fusekernel.OutHeader) { // Grow the buffer by the supplied number of bytes, returning a pointer to the // start of the new segment. The sum of the arguments given to Grow must not // exceed the argument given to New when creating the buffer. -func (b *Buffer) Grow(size uintptr) (p unsafe.Pointer) { +func (b *OutMessage) Grow(size uintptr) (p unsafe.Pointer) { sh := (*reflect.SliceHeader)(unsafe.Pointer(&b.slice)) p = unsafe.Pointer(sh.Data + uintptr(sh.Len)) b.slice = b.slice[:len(b.slice)+int(size)] @@ -56,7 +56,7 @@ func (b *Buffer) Grow(size uintptr) (p unsafe.Pointer) { } // Equivalent to growing by the length of p, then copying p into the new segment. -func (b *Buffer) Append(p []byte) { +func (b *OutMessage) Append(p []byte) { sh := reflect.SliceHeader{ Data: uintptr(b.Grow(uintptr(len(p)))), Len: len(p), @@ -67,7 +67,7 @@ func (b *Buffer) Append(p []byte) { } // Equivalent to growing by the length of s, then copying s into the new segment. -func (b *Buffer) AppendString(s string) { +func (b *OutMessage) AppendString(s string) { sh := reflect.SliceHeader{ Data: uintptr(b.Grow(uintptr(len(s)))), Len: len(s), @@ -78,6 +78,6 @@ func (b *Buffer) AppendString(s string) { } // Return a reference to the current contents of the buffer. -func (b *Buffer) Bytes() []byte { +func (b *OutMessage) Bytes() []byte { return b.slice }