// NewSurface build and allocates all the memory to create
// a surface defined by the bound represented by width*height discrete points.
// Note that surface.Grid[width-1][height-1] will be on the boundary of the bound.
182084
func NewSurface(bound *Bound, width, height int) *Surface {
	s := &Surface{
		bound:  bound.Clone(),
		Width:  width,
		Height: height,
	}

	s.Grid = make([][]float64, width)
	points := make([]float64, width*height)

	for i := range s.Grid {
		s.Grid[i], points = points[:height], points[height:]
	}

	return s
}
653890
func NewServiceMap(services []service.ServiceDetails) ServiceMap {
	var smap = make(ServiceMap)
	for _, s := range services {
		smap.Add(s)
	}
	return smap
}
222015
func CreateSoftwareRenderer(surface *Surface) (*Renderer, error) {
	renderer := C.SDL_CreateSoftwareRenderer(surface.cptr())
	if renderer == nil {
		return nil, GetError()
	}
	return (*Renderer)(unsafe.Pointer(renderer)), nil
}
495619
func CreateRGBSurfaceFrom(pixels unsafe.Pointer, width, height int32, depth, pitch int, Rmask, Gmask, Bmask, Amask uint32) (*Surface, error) {
	surface := (*Surface)(unsafe.Pointer(C.SDL_CreateRGBSurfaceFrom(
		pixels,
		C.int(width),
		C.int(height),
		C.int(depth),
		C.int(pitch),
		C.Uint32(Rmask),
		C.Uint32(Gmask),
		C.Uint32(Bmask),
		C.Uint32(Amask))))
	if surface == nil {
		return nil, GetError()
	}
	return surface, nil
}
117921
func NewServer(options ...Option) *Server {
	s := &Server{
		subscriptions: make(map[string]map[string]query.Query),
	}
	s.BaseService = *common.NewBaseService(nil, "PubSub", s)

	for _, option := range options {
		option(s)
	}

	// if BufferCapacity option was not set, the channel is unbuffered
	s.cmds = make(chan cmd, s.cmdsCap)

	return s
}
1135653
func newStructDef(apiDef *raml.APIDefinition, name, packageName, description string, properties map[string]interface{}) structDef {
	// generate struct's fields from type properties
	fields := make(map[string]fieldDef)
	for k, v := range properties {
		prop := raml.ToProperty(k, v)
		fields[prop.Name] = newFieldDef(apiDef, name, prop, packageName)
	}
	return structDef{
		Name:        strings.Title(commons.NormalizeIdentifier(name)),
		PackageName: packageName,
		Fields:      fields,
		Description: commons.ParseDescription(description),
	}
}
345884
func NewStructuralCopy(of FixedDataGrid) *DenseInstances {
	ret, _, _ := copyFixedDataGridStructure(of)
	return ret
}
906510
func uvwFace(face, axis, direction int) int {
	return faceUVWFaces[face][axis][direction]
}
418921
func NewSetVisibleSizeArgs(width int, height int) *SetVisibleSizeArgs {
	args := new(SetVisibleSizeArgs)
	args.Width = width
	args.Height = height
	return args
}
341319
func (c *Connect) NumOfInterfaces() (int, error) {
	var err C.virError
	result := int(C.virConnectNumOfInterfacesWrapper(c.ptr, &err))
	if result == -1 {
		return 0, makeError(&err)
	}
	return result, nil
}
208401
func NewServer(kind, name, addr, namespace string) *services.ServerV2 {
	return &services.ServerV2{
		Kind:    kind,
		Version: services.V2,
		Metadata: services.Metadata{
			Name:      name,
			Namespace: namespace,
		},
		Spec: services.ServerSpecV2{
			Addr:       addr,
			PublicAddr: addr,
		},
	}
}
1188967
func NewSpatialTransformer(samplerType SamplerType, dataType DataType, nbDims int, dimA []int) (retVal *SpatialTransformer, err error) {
	var internal C.cudnnSpatialTransformerDescriptor_t
	if err := result(C.cudnnCreateSpatialTransformerDescriptor(&internal)); err != nil {
		return nil, err
	}

	dimAC, dimACManaged := ints2CIntPtr(dimA)
	defer returnManaged(dimACManaged)
	if err := result(C.cudnnSetSpatialTransformerNdDescriptor(internal, samplerType.C(), dataType.C(), C.int(nbDims), dimAC)); err != nil {
		return nil, err
	}

	retVal = &SpatialTransformer{
		internal:    internal,
		samplerType: samplerType,
		dataType:    dataType,
		nbDims:      nbDims,
		dimA:        dimA,
	}
	runtime.SetFinalizer(retVal, destroySpatialTransformer)
	return retVal, nil
}
748847
func (s *InternalLBService) NewStartInternalLoadBalancerVMParams(id string) *StartInternalLoadBalancerVMParams {
	p := &StartInternalLoadBalancerVMParams{}
	p.p = make(map[string]interface{})
	p.p["id"] = id
	return p
}
959482
func XlibSurfaceCreateForBitmap(dpy unsafe.Pointer, bitmap uint64, screen unsafe.Pointer, width, height int) *XlibSurface {
	ret := &XlibSurface{wrapSurface(C.cairo_xlib_surface_create_for_bitmap((*C.Display)(dpy), C.Pixmap(bitmap), (*C.Screen)(screen), C.int(width), C.int(height)))}
	if err := ret.status(); err != nil {
		panic(err)
	}
	return ret
}
158714
func WebPageResolver(article *Article) string {
	candidates, significantSurfaceCount := WebPageImageResolver(article.Doc)
	if candidates == nil {
		return ""
	}
	var bestCandidate candidate
	var topImage string
	if significantSurfaceCount > 0 {
		bestCandidate = findBestCandidateFromSurface(candidates)
	} else {
		bestCandidate = findBestCandidateFromScore(candidates)
	}

	topImage = bestCandidate.url
	a, err := url.Parse(topImage)
	if err != nil {
		return topImage
	}
	finalURL, err := url.Parse(article.FinalURL)
	if err != nil {
		return topImage
	}
	b := finalURL.ResolveReference(a)
	topImage = b.String()

	return topImage
}
409115
func NewServer(bindHost string, bindPort int) (*Server, error) {
	addr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", bindHost, bindPort))
	if err != nil {
		return nil, err
	}
	c, err := net.ListenUDP("udp", addr)
	if err != nil {
		return nil, err
	}
	return &Server{
		conn:          c,
		storageQueue:  make(chan string, queueSize),
		drainageQueue: make(chan string, queueSize),
	}, nil
}
875296
func LoadTextureRW(renderer *sdl.Renderer, src *sdl.RWops, freesrc bool) (*sdl.Texture, error) {
	_renderer := (*C.SDL_Renderer)(unsafe.Pointer(renderer))
	_src := (*C.SDL_RWops)(unsafe.Pointer(src))
	_freesrc := (C.int)(sdl.Btoi(freesrc))
	_surface := C.IMG_LoadTexture_RW(_renderer, _src, _freesrc)
	if _surface == nil {
		return nil, GetError()
	}
	return (*sdl.Texture)(unsafe.Pointer(_surface)), nil
}