package av
import (
- "bytes";
"exp/draw";
"exp/nacl/srpc";
"log";
if r == bridge.share.eq.wi {
return noEvents
}
- bytes.Copy(ev, &bridge.share.eq.event[r]);
+ copy(ev, &bridge.share.eq.event[r]);
bridge.share.eq.ri = (r + 1) % eqsize;
return nil;
}
package srpc
import (
- "bytes";
"math";
"os";
"strconv";
// returned the total byte count as n.
m := new(msg);
m.rdata = make([]byte, n);
- bytes.Copy(m.rdata, &r.data);
+ copy(m.rdata, &r.data);
// Make a copy of the desc too.
// The system call *did* update r.hdr.ndesc.
i := len(m.wdata);
if i+n > cap(m.wdata) {
a := make([]byte, i, (i+n)*2);
- bytes.Copy(a, m.wdata);
+ copy(a, m.wdata);
m.wdata = a;
}
m.wdata = m.wdata[0 : i+n];
b[7] = byte(hi >> 24);
}
-func (m *msg) wbytes(p []byte) { bytes.Copy(m.grow(len(p)), p) }
+func (m *msg) wbytes(p []byte) { copy(m.grow(len(p)), p) }
func (m *msg) wstring(s string) {
b := m.grow(len(s));
//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.
if errno != 0 {
return 0, errno
}
- n += bytesCopy(out, buf[addr%sizeofPtr:]);
+ n += copy(out, buf[addr%sizeofPtr:]);
out = out[n:];
}
if errno != 0 {
return n, errno
}
- copied := bytesCopy(out, &buf);
+ copied := copy(out, &buf);
n += copied;
out = out[copied:];
}
if errno != 0 {
return 0, errno
}
- n += bytesCopy(buf[addr%sizeofPtr:], data);
+ n += copy(buf[addr%sizeofPtr:], data);
word := *((*uintptr)(unsafe.Pointer(&buf[0])));
errno = ptrace(pokeReq, pid, addr-addr%sizeofPtr, word);
if errno != 0 {
if errno != 0 {
return n, errno
}
- bytesCopy(&buf, data);
+ copy(&buf, data);
word := *((*uintptr)(unsafe.Pointer(&buf[0])));
errno = ptrace(pokeReq, pid, addr+uintptr(n), word);
if errno != 0 {