Use len(... instead of sizeof in C_RTMP_SetupUrl

This commit is contained in:
saxon 2018-08-10 16:43:19 +09:30
parent 358e32d2ac
commit db2f6a4756
1 changed files with 6 additions and 6 deletions

View File

@ -500,11 +500,11 @@ func C_RTMP_Init(r *C.RTMP) {
func C_RTMP_SetupURL(r *C.RTMP, u string) int32 { func C_RTMP_SetupURL(r *C.RTMP, u string) int32 {
url := goStrToCStr(u) url := goStrToCStr(u)
var ret, len int32 var ret, length int32
var port uint32 var port uint32
port = 0 port = 0
len = strlen(url) length = strlen(url)
// TODO: port this // TODO: port this
ret = int32(C.RTMP_ParseURL((*C.char)(unsafe.Pointer(url)), &r.Link.protocol, &r.Link.hostname, ret = int32(C.RTMP_ParseURL((*C.char)(unsafe.Pointer(url)), &r.Link.protocol, &r.Link.hostname,
(*C.uint)(&port), &r.Link.playpath0, &r.Link.app)) (*C.uint)(&port), &r.Link.playpath0, &r.Link.app))
@ -520,16 +520,16 @@ func C_RTMP_SetupURL(r *C.RTMP, u string) int32 {
r.Link.tcUrl.av_val = (*C.char)(unsafe.Pointer(url)) r.Link.tcUrl.av_val = (*C.char)(unsafe.Pointer(url))
if r.Link.app.av_len != 0 { if r.Link.app.av_len != 0 {
if int(uintptr(unsafe.Pointer(r.Link.app.av_val))) < if int(uintptr(unsafe.Pointer(r.Link.app.av_val))) <
int(uintptr(incBytePtr(unsafe.Pointer(url), int(len)))) { int(uintptr(incBytePtr(unsafe.Pointer(url), int(length)))) {
r.Link.tcUrl.av_len = C.int(int(r.Link.app.av_len) + r.Link.tcUrl.av_len = C.int(int(r.Link.app.av_len) +
int(uintptr(decBytePtr(unsafe.Pointer(r.Link.app.av_val), int(uintptr(decBytePtr(unsafe.Pointer(r.Link.app.av_val),
int(uintptr(unsafe.Pointer(url))))))) int(uintptr(unsafe.Pointer(url)))))))
} else { } else {
len = int32(r.Link.hostname.av_len) + int32(r.Link.app.av_len) + length = int32(r.Link.hostname.av_len) + int32(r.Link.app.av_len) +
int32(unsafe.Sizeof("rtmpte://:65535/")) int32(len("rtmpte://:65535/\x00"))
r.Link.tcUrl.av_val = (*C.char)(allocate(uintptr(len))) r.Link.tcUrl.av_val = (*C.char)(allocate(uintptr(length)))
hostname := string(ptrToSlice(unsafe.Pointer(r.Link.hostname.av_val), hostname := string(ptrToSlice(unsafe.Pointer(r.Link.hostname.av_val),
int(r.Link.hostname.av_len))) int(r.Link.hostname.av_len)))