func Gets() (s string) { cs := C.getstring() if cs == nil { panic("input.Gets: I/O error or out of memory") } s = C.GoString(cs) C.free(unsafe.Pointer(cs)) return }
func (p *Comment) UserComments() (UserComments []string) { if p.user_comments == nil { return nil } UserComments = make([]string, int(p.comments)) for i := 0; i < int(p.comments); i++ { UserComments[i] = C.GoString(C.getstring(p.user_comments, C.int(i))) } return }
//Get hostnames where a particular block (determined by pos & blocksize) of a file is stored. //path: The path of the file. //start: The start of the block. //length: The length of the block. //Returns a 2-D slice of blocks-hosts, or nil on error. func (fs *Fs) GetHosts(path string, start, length int64) ([][]string, error) { p := C.CString(path) defer C.free(unsafe.Pointer(p)) ret, err := C.hdfsGetHosts(fs.cptr, p, C.tOffset(start), C.tOffset(length)) if ret == (***C.char)(unsafe.Pointer(uintptr(0))) { return nil, err } defer C.hdfsFreeHosts(ret) i := int(C.getlen(ret)) j := int(C.getl(ret)) s := make([][]string, i) for k, _ := range s { s[k] = make([]string, j) for p, _ := range s[k] { s[k][p] = C.GoString(C.getstring(ret, C.int(k), C.int(p))) } } return s, nil }