Commit a25c297e authored by Aaron Jacobs's avatar Aaron Jacobs

OutMessage.AppendString

parent bb88db68
......@@ -103,8 +103,16 @@ func (b *OutMessage) Append(src []byte) {
// Equivalent to growing by the length of s, then copying s over the new
// segment. Panics if there is not enough room available.
func (b *OutMessage) AppendString(s string) {
panic("TODO")
func (b *OutMessage) AppendString(src string) {
p := b.GrowNoZero(uintptr(len(src)))
if p == nil {
panic(fmt.Sprintf("Can't grow %d bytes", len(src)))
}
sh := (*reflect.StringHeader)(unsafe.Pointer(&src))
memmove(p, unsafe.Pointer(sh.Data), uintptr(sh.Len))
return
}
// Return the current size of the buffer.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment