convert *[] to [].
R=r
OCL=21563
CL=21571
diff --git a/src/lib/io/bytebuffer.go b/src/lib/io/bytebuffer.go
index 8af8a09..d06f148 100644
--- a/src/lib/io/bytebuffer.go
+++ b/src/lib/io/bytebuffer.go
@@ -16,7 +16,7 @@
// TODO(r): Do better memory management.
-func bytecopy(dst *[]byte, doff int, src *[]byte, soff int, count int) {
+func bytecopy(dst []byte, doff int, src []byte, soff int, count int) {
for i := 0; i < count; i++ {
dst[doff] = src[soff];
doff++;
@@ -25,7 +25,7 @@
}
export type ByteBuffer struct {
- buf *[]byte;
+ buf []byte;
off int; // Read from here
len int; // Write to here
cap int;
@@ -36,9 +36,9 @@
b.len = 0;
}
-func (b *ByteBuffer) Write(p *[]byte) (n int, err *os.Error) {
+func (b *ByteBuffer) Write(p []byte) (n int, err *os.Error) {
plen := len(p);
- if b.buf == nil {
+ if len(b.buf) == 0 {
b.cap = plen + 1024;
b.buf = new([]byte, b.cap);
b.len = 0;
@@ -54,9 +54,9 @@
return plen, nil;
}
-func (b *ByteBuffer) Read(p *[]byte) (n int, err *os.Error) {
+func (b *ByteBuffer) Read(p []byte) (n int, err *os.Error) {
plen := len(p);
- if b.buf == nil {
+ if len(b.buf) == 0 {
return 0, nil
}
if b.off == b.len { // empty buffer
@@ -75,20 +75,12 @@
return b.len
}
-// If the buffer is empty, Data() should still give a valid array.
-// Use this variable as a surrogate. It's immutable (can't be
-// grown, can't store any data) so it's safe to share.
-var EmptyByteArray = new([]byte, 0)
-
-func (b *ByteBuffer) Data() *[]byte {
- if b.buf == nil {
- return EmptyByteArray
- }
+func (b *ByteBuffer) Data() []byte {
return b.buf[b.off:b.len]
}
-export func NewByteBufferFromArray(buf *[]byte) *ByteBuffer {
+export func NewByteBufferFromArray(buf []byte) *ByteBuffer {
b := new(ByteBuffer);
b.buf = buf;
b.off = 0;
diff --git a/src/lib/io/io.go b/src/lib/io/io.go
index 26c2aaa..af6a9fe 100644
--- a/src/lib/io/io.go
+++ b/src/lib/io/io.go
@@ -12,21 +12,21 @@
export var ErrEOF = os.NewError("EOF")
export type Read interface {
- Read(p *[]byte) (n int, err *os.Error);
+ Read(p []byte) (n int, err *os.Error);
}
export type Write interface {
- Write(p *[]byte) (n int, err *os.Error);
+ Write(p []byte) (n int, err *os.Error);
}
export type ReadWrite interface {
- Read(p *[]byte) (n int, err *os.Error);
- Write(p *[]byte) (n int, err *os.Error);
+ Read(p []byte) (n int, err *os.Error);
+ Write(p []byte) (n int, err *os.Error);
}
export type ReadWriteClose interface {
- Read(p *[]byte) (n int, err *os.Error);
- Write(p *[]byte) (n int, err *os.Error);
+ Read(p []byte) (n int, err *os.Error);
+ Write(p []byte) (n int, err *os.Error);
Close() *os.Error;
}
@@ -41,7 +41,7 @@
}
// Read until buffer is full, EOF, or error
-export func Readn(fd Read, buf *[]byte) (n int, err *os.Error) {
+export func Readn(fd Read, buf []byte) (n int, err *os.Error) {
n = 0;
for n < len(buf) {
nn, e := fd.Read(buf[n:len(buf)]);
@@ -64,7 +64,7 @@
fd Read;
}
-func (fd *FullRead) Read(p *[]byte) (n int, err *os.Error) {
+func (fd *FullRead) Read(p []byte) (n int, err *os.Error) {
n, err = Readn(fd.fd, p);
return n, err
}
@@ -147,7 +147,7 @@
// Convert a string to an array of bytes for easy marshaling.
// Could fill with syscall.StringToBytes but it adds an unnecessary \000
// so the length would be wrong.
-export func StringBytes(s string) *[]byte {
+export func StringBytes(s string) []byte {
b := new([]byte, len(s));
for i := 0; i < len(s); i++ {
b[i] = s[i];