diff --git a/rtmp/rtmp.go b/rtmp/rtmp.go index e3837b74..1e85e12a 100644 --- a/rtmp/rtmp.go +++ b/rtmp/rtmp.go @@ -281,9 +281,9 @@ func C_SocksSetup(r *C_RTMP, sockshost *C_AVal) { r.Link.sockshost.av_val = (*byte)(unsafe.Pointer(hostname)) r.Link.sockshost.av_len = int32(strlen(hostname)) - value, err := strconv.Atoi(string(ptrToSlice(unsafe.Pointer(uintptr( - unsafe.Pointer(socksport))+uintptr(1)), int(strlen((*byte)(unsafe.Pointer( - uintptr(unsafe.Pointer(socksport))+uintptr(1)))))+1))) + value, err := strconv.Atoi(string((*[_Gi]byte)(unsafe.Pointer(uintptr( + unsafe.Pointer(socksport)) + uintptr(1)))[:int(strlen((*byte)(unsafe.Pointer( + uintptr(unsafe.Pointer(socksport))+uintptr(1)))))+1])) if err != nil { log.Println("C_SocksSetup: bad string conversion!") } @@ -337,11 +337,9 @@ func C_RTMP_SetupURL(r *C_RTMP, u string) int32 { int32(len("rtmpte://:65535/\x00")) r.Link.tcUrl.av_val = (*byte)(malloc(uintptr(uintptr(length)))) - hostname := string(ptrToSlice(unsafe.Pointer(r.Link.hostname.av_val), - int(r.Link.hostname.av_len))) + hostname := string((*[_Gi]byte)(unsafe.Pointer(r.Link.hostname.av_val))[:int(r.Link.hostname.av_len)]) - app := string(ptrToSlice(unsafe.Pointer(r.Link.app.av_val), - int(r.Link.app.av_len))) + app := string((*[_Gi]byte)(unsafe.Pointer(r.Link.app.av_val))[:int(r.Link.app.av_len)]) fString := fmt.Sprintf("%v://%v:%v/%v", RTMPProtocolStringsLower[r.Link.protocol], hostname, r.Link.port, app) @@ -2263,14 +2261,14 @@ func goStrToCStr(str string) *byte { // TODO: need a test in rtmp_test.go func cStrToGoStr(cStr *byte) string { - return string(ptrToSlice(unsafe.Pointer(cStr), int(strlen(cStr)))) + return string((*[_Gi]byte)(unsafe.Pointer(cStr))[:int(strlen(cStr))]) } // Duplicates a string given as a byte pointer func strdup(str *byte) *byte { length := strlen(str) newMem := make([]byte, length+1) - oldMem := ptrToSlice(unsafe.Pointer(str), int(length+1)) + oldMem := (*[_Gi]byte)(unsafe.Pointer(str))[:int(length+1)] copy(newMem, oldMem) return &newMem[0] }