internal/graphicsdriver/opengl/gl/conversions_notwindows.go
func Strs(strs ...string) (cstrs **uint8, free func()) {
	if len(strs) == 0 {
		panic("Strs: expected at least 1 string")
	}

	// Allocate a contiguous array large enough to hold all the strings' contents.
	n := 0
	for i := range strs {
		n += len(strs[i])
	}
	data := C.malloc(C.size_t(n))

	// Copy all the strings into data.
	dataSlice := *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{
		Data: uintptr(data),
		Len:  n,
		Cap:  n,
	}))
	css := make([]*uint8, len(strs)) // Populated with pointers to each string.
	offset := 0
	for i := range strs {
		copy(dataSlice[offset:offset+len(strs[i])], strs[i][:]) // Copy strs[i] into proper data location.
		css[i] = (*uint8)(unsafe.Pointer(&dataSlice[offset]))   // Set a pointer to it.
		offset += len(strs[i])
	}

	return (**uint8)(&css[0]), func() { C.free(data) }
}
func Strs(strs ...string) (cstrs **uint8, free func()) {
	if len(strs) == 0 {
		panic("Strs: expected at least 1 string")
	}

	// Allocate a contiguous array large enough to hold all the strings' contents.
	n := 0
	for i := range strs {
		n += len(strs[i])
	}
	data := C.malloc(C.size_t(n))

	// Copy all the strings into data.
	dataSlice := *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{
		Data: uintptr(data),
		Len:  n,
		Cap:  n,
	}))
	css := make([]*uint8, len(strs)) // Populated with pointers to each string.
	offset := 0
	for i := range strs {
		copy(dataSlice[offset:offset+len(strs[i])], strs[i][:]) // Copy strs[i] into proper data location.
		css[i] = (*uint8)(unsafe.Pointer(&dataSlice[offset]))   // Set a pointer to it.
		offset += len(strs[i])
	}

	return (**uint8)(&css[0]), func() { C.free(data) }
}
func Strs ( strs ... string ) ( cstrs * * uint8 , free func ( ) ) { if len ( strs ) == 0 { panic ( " " ) } // Allocate a contiguous array large enough to hold all the strings' contents. n := 0 for i := range strs { n += len ( strs [ i ] ) } data := C . malloc ( C . size_t ( n ) ) // Copy all the strings into data. dataSlice := * ( * [ ] byte ) ( unsafe . Pointer ( & reflect . SliceHeader { Data : uintptr ( data ) , Len : n , Cap : n , } ) ) css := make ( [ ] * uint8 , len ( strs ) ) // Populated with pointers to each string. offset := 0 for i := range strs { copy ( dataSlice [ offset : offset + len ( strs [ i ] ) ] , strs [ i ] [ : ] ) // Copy strs[i] into proper data location. css [ i ] = ( * uint8 ) ( unsafe . Pointer ( & dataSlice [ offset ] ) ) // Set a pointer to it. offset += len ( strs [ i ] ) } return ( * * uint8 ) ( & css [ 0 ] ) , func ( ) { C . free ( data ) } }
// Strs takes a list of Go strings (with or without null-termination) and
// returns their C counterpart.
//
// The returned free function must be called once you are done using the strings
// in order to free the memory.
//
// If no strings are provided as a parameter this function will panic.
Strs takes a list of Go strings ( with or without null - termination ) and returns their C counterpart . The returned free function must be called once you are done using the strings in order to free the memory . If no strings are provided as a parameter this function will panic .