mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
new new & make
R=r OCL=22166 CL=22166
This commit is contained in:
parent
9662e7b2db
commit
5564504507
113 changed files with 363 additions and 364 deletions
|
|
@ -40,12 +40,12 @@ func (b *ByteBuffer) Write(p []byte) (n int, err *os.Error) {
|
|||
plen := len(p);
|
||||
if len(b.buf) == 0 {
|
||||
b.cap = plen + 1024;
|
||||
b.buf = new([]byte, b.cap);
|
||||
b.buf = make([]byte, b.cap);
|
||||
b.len = 0;
|
||||
}
|
||||
if b.len + len(p) > b.cap {
|
||||
b.cap = 2*(b.cap + plen);
|
||||
nb := new([]byte, b.cap);
|
||||
nb := make([]byte, b.cap);
|
||||
bytecopy(nb, 0, b.buf, 0, b.len);
|
||||
b.buf = nb;
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ func (b *ByteBuffer) Data() []byte {
|
|||
|
||||
|
||||
export func NewByteBufferFromArray(buf []byte) *ByteBuffer {
|
||||
b := new(*ByteBuffer);
|
||||
b := new(ByteBuffer);
|
||||
b.buf = buf;
|
||||
b.off = 0;
|
||||
b.len = len(buf);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue