Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
f0c97195
Commit
f0c97195
authored
Nov 30, 2009
by
Christopher Wedgwood
Committed by
Russ Cox
Nov 30, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minimise bitrot: bytes.Copy -> copy
(compile tested only) R=r, rsc
https://golang.org/cl/161069
parent
cd9d72ba
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
24 deletions
+10
-24
av.go
src/pkg/exp/nacl/av/av.go
+1
-2
event.go
src/pkg/exp/nacl/av/event.go
+2
-3
msg.go
src/pkg/exp/nacl/srpc/msg.go
+3
-4
syscall_linux.go
src/pkg/syscall/syscall_linux.go
+4
-15
No files found.
src/pkg/exp/nacl/av/av.go
View file @
f0c97195
...
...
@@ -12,7 +12,6 @@
package
av
import
(
"bytes"
;
"exp/draw"
;
"exp/nacl/srpc"
;
"log"
;
...
...
@@ -158,7 +157,7 @@ func videoPollEvent(ev []byte) (err os.Error) {
if
r
==
bridge
.
share
.
eq
.
wi
{
return
noEvents
}
bytes
.
C
opy
(
ev
,
&
bridge
.
share
.
eq
.
event
[
r
]);
c
opy
(
ev
,
&
bridge
.
share
.
eq
.
event
[
r
]);
bridge
.
share
.
eq
.
ri
=
(
r
+
1
)
%
eqsize
;
return
nil
;
}
...
...
src/pkg/exp/nacl/av/event.go
View file @
f0c97195
...
...
@@ -10,8 +10,7 @@
package
av
import
(
"bytes"
;
"debug/binary"
;
"encoding/binary"
;
"exp/draw"
;
"log"
;
"os"
;
...
...
@@ -383,7 +382,7 @@ func (r *reader) Read(p []byte) (n int, err os.Error) {
if
len
(
b
)
==
0
&&
len
(
p
)
>
0
{
return
0
,
os
.
EOF
}
n
=
bytes
.
C
opy
(
p
,
b
);
n
=
c
opy
(
p
,
b
);
*
r
=
b
[
n
:
];
return
;
}
...
...
src/pkg/exp/nacl/srpc/msg.go
View file @
f0c97195
...
...
@@ -7,7 +7,6 @@
package
srpc
import
(
"bytes"
;
"math"
;
"os"
;
"strconv"
;
...
...
@@ -121,7 +120,7 @@ func (r *msgReceiver) recv() (*msg, os.Error) {
// returned the total byte count as n.
m
:=
new
(
msg
);
m
.
rdata
=
make
([]
byte
,
n
);
bytes
.
C
opy
(
m
.
rdata
,
&
r
.
data
);
c
opy
(
m
.
rdata
,
&
r
.
data
);
// Make a copy of the desc too.
// The system call *did* update r.hdr.ndesc.
...
...
@@ -219,7 +218,7 @@ func (m *msg) grow(n int) []byte {
i
:=
len
(
m
.
wdata
);
if
i
+
n
>
cap
(
m
.
wdata
)
{
a
:=
make
([]
byte
,
i
,
(
i
+
n
)
*
2
);
bytes
.
C
opy
(
a
,
m
.
wdata
);
c
opy
(
a
,
m
.
wdata
);
m
.
wdata
=
a
;
}
m
.
wdata
=
m
.
wdata
[
0
:
i
+
n
];
...
...
@@ -250,7 +249,7 @@ func (m *msg) wuint64(x uint64) {
b
[
7
]
=
byte
(
hi
>>
24
);
}
func
(
m
*
msg
)
wbytes
(
p
[]
byte
)
{
bytes
.
C
opy
(
m
.
grow
(
len
(
p
)),
p
)
}
func
(
m
*
msg
)
wbytes
(
p
[]
byte
)
{
c
opy
(
m
.
grow
(
len
(
p
)),
p
)
}
func
(
m
*
msg
)
wstring
(
s
string
)
{
b
:=
m
.
grow
(
len
(
s
));
...
...
src/pkg/syscall/syscall_linux.go
View file @
f0c97195
...
...
@@ -385,17 +385,6 @@ func Sendto(fd int, p []byte, flags int, to Sockaddr) (errno int) {
//sys ptrace(request int, pid int, addr uintptr, data uintptr) (errno int)
// See bytes.Copy.
func
bytesCopy
(
dst
,
src
[]
byte
)
int
{
if
len
(
src
)
>
len
(
dst
)
{
src
=
src
[
0
:
len
(
dst
)]
}
for
i
,
x
:=
range
src
{
dst
[
i
]
=
x
}
return
len
(
src
);
}
func
ptracePeek
(
req
int
,
pid
int
,
addr
uintptr
,
out
[]
byte
)
(
count
int
,
errno
int
)
{
// The peek requests are machine-size oriented, so we wrap it
// to retrieve arbitrary-length data.
...
...
@@ -416,7 +405,7 @@ func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, errno in
if
errno
!=
0
{
return
0
,
errno
}
n
+=
bytesC
opy
(
out
,
buf
[
addr
%
sizeofPtr
:
]);
n
+=
c
opy
(
out
,
buf
[
addr
%
sizeofPtr
:
]);
out
=
out
[
n
:
];
}
...
...
@@ -428,7 +417,7 @@ func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, errno in
if
errno
!=
0
{
return
n
,
errno
}
copied
:=
bytesC
opy
(
out
,
&
buf
);
copied
:=
c
opy
(
out
,
&
buf
);
n
+=
copied
;
out
=
out
[
copied
:
];
}
...
...
@@ -456,7 +445,7 @@ func ptracePoke(pokeReq int, peekReq int, pid int, addr uintptr, data []byte) (c
if
errno
!=
0
{
return
0
,
errno
}
n
+=
bytesC
opy
(
buf
[
addr
%
sizeofPtr
:
],
data
);
n
+=
c
opy
(
buf
[
addr
%
sizeofPtr
:
],
data
);
word
:=
*
((
*
uintptr
)(
unsafe
.
Pointer
(
&
buf
[
0
])));
errno
=
ptrace
(
pokeReq
,
pid
,
addr
-
addr
%
sizeofPtr
,
word
);
if
errno
!=
0
{
...
...
@@ -483,7 +472,7 @@ func ptracePoke(pokeReq int, peekReq int, pid int, addr uintptr, data []byte) (c
if
errno
!=
0
{
return
n
,
errno
}
bytesC
opy
(
&
buf
,
data
);
c
opy
(
&
buf
,
data
);
word
:=
*
((
*
uintptr
)(
unsafe
.
Pointer
(
&
buf
[
0
])));
errno
=
ptrace
(
pokeReq
,
pid
,
addr
+
uintptr
(
n
),
word
);
if
errno
!=
0
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment