https://github.com/opencontainers/runc/releases/tag/v1.0.0-rc91 Signed-off-by: Davanum Srinivas <davanum@gmail.com>
		
			
				
	
	
		
			31 lines
		
	
	
		
			665 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			665 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package internal
 | 
						|
 | 
						|
import "unsafe"
 | 
						|
 | 
						|
// NewPointer creates a 64-bit pointer from an unsafe Pointer.
 | 
						|
func NewPointer(ptr unsafe.Pointer) Pointer {
 | 
						|
	return Pointer{ptr: ptr}
 | 
						|
}
 | 
						|
 | 
						|
// NewSlicePointer creates a 64-bit pointer from a byte slice.
 | 
						|
func NewSlicePointer(buf []byte) Pointer {
 | 
						|
	if len(buf) == 0 {
 | 
						|
		return Pointer{}
 | 
						|
	}
 | 
						|
 | 
						|
	return Pointer{ptr: unsafe.Pointer(&buf[0])}
 | 
						|
}
 | 
						|
 | 
						|
// NewStringPointer creates a 64-bit pointer from a string.
 | 
						|
func NewStringPointer(str string) Pointer {
 | 
						|
	if str == "" {
 | 
						|
		return Pointer{}
 | 
						|
	}
 | 
						|
 | 
						|
	// The kernel expects strings to be zero terminated
 | 
						|
	buf := make([]byte, len(str)+1)
 | 
						|
	copy(buf, str)
 | 
						|
 | 
						|
	return Pointer{ptr: unsafe.Pointer(&buf[0])}
 | 
						|
}
 |