rtmp: simplify indexing

This is a mechanical change in line with the previous:

gofmt -w -r '*indxBytePtr(p,i)->(*[_Gi]byte)(p)[i]' {rtmp,parseurl,amf}.go
This commit is contained in:
Dan Kortschak 2018-08-31 11:29:41 +09:30
parent 18e1e7fc45
commit 0053034e94
1 changed files with 9 additions and 9 deletions

View File

@ -1190,7 +1190,7 @@ func C_AV_queue(vals **C_RTMP_METHOD, num *int32, av *C_AVal, txn int32) {
tmp := malloc(uintptr(av.av_len + 1))
//tmp := allocate(uintptr(av.av_len + 1))
memmove(tmp, unsafe.Pointer(av.av_val), uintptr(av.av_len))
*indxBytePtr(tmp, int(av.av_len)) = '\000'
(*[_Gi]byte)(tmp)[int(av.av_len)] = '\000'
(*(*C_RTMP_METHOD)(incPtr(unsafe.Pointer(*vals), int(*num),
int(unsafe.Sizeof(*(*vals)))))).num = int32(txn)
@ -1916,10 +1916,10 @@ func C_RTMP_SendPacket(r *C_RTMP, packet *C_RTMPPacket, queue int) int {
if cSize != 0 {
tmp := int(packet.m_nChannel) - 64
*indxBytePtr(header, 1) = byte(tmp & 0xff)
(*[_Gi]byte)(header)[1] = byte(tmp & 0xff)
if cSize == 2 {
*indxBytePtr(header, 2) = byte(tmp >> 8)
(*[_Gi]byte)(header)[2] = byte(tmp >> 8)
}
}
if t >= 0xffffff {
@ -2131,18 +2131,18 @@ func C_RTMP_Write(r *C_RTMP, data []byte) int {
return 0
}
if *indxBytePtr(buf, 0) == 'F' && *indxBytePtr(buf, 1) == 'L' && *indxBytePtr(buf, 2) == 'V' {
if (*[_Gi]byte)(buf)[0] == 'F' && (*[_Gi]byte)(buf)[1] == 'L' && (*[_Gi]byte)(buf)[2] == 'V' {
buf = unsafe.Pointer(uintptr(buf) + uintptr(13))
s2 -= 13
}
pkt.m_packetType = uint8(*indxBytePtr(buf, 0))
pkt.m_packetType = uint8((*[_Gi]byte)(buf)[0])
buf = incBytePtr(buf, 1)
pkt.m_nBodySize = uint32(C_AMF_DecodeInt24((*byte)(buf)))
buf = incBytePtr(buf, 3)
pkt.m_nTimeStamp = uint32(C_AMF_DecodeInt24((*byte)(buf)))
buf = incBytePtr(buf, 3)
pkt.m_nTimeStamp |= uint32(*indxBytePtr(buf, 0)) << 24
pkt.m_nTimeStamp |= uint32((*[_Gi]byte)(buf)[0]) << 24
buf = incBytePtr(buf, 4)
s2 -= 11
@ -2221,8 +2221,8 @@ func memmove(to, from unsafe.Pointer, n uintptr) {
// TODO: write test for this func
func memcmp(a, b unsafe.Pointer, size int) int {
for i := 0; i < size; i++ {
aValue := *indxBytePtr(a, i)
bValue := *indxBytePtr(b, i)
aValue := (*[_Gi]byte)(a)[i]
bValue := (*[_Gi]byte)(b)[i]
if aValue != bValue {
if aValue < bValue {
return -1
@ -2255,7 +2255,7 @@ func goStrToCStr(str string) *byte {
slice := make([]byte, l+1)
ptr := unsafe.Pointer(&[]byte(str)[0])
for i := 0; i < l; i++ {
slice[i] = *indxBytePtr(ptr, i)
slice[i] = (*[_Gi]byte)(ptr)[i]
}
slice[l] = '\x00'
return &slice[0]