// Frees an IP in the pool, returns an error if the IP is already free
775691
func (dp *DHCPPool) FreeIPIndex(index uint64) error {
	dp.lock.Lock()
	defer dp.lock.Unlock()

	if !dp.IndexInPool(index) {
		return errors.New("Trying to free an IP that is outside the capacity of this pool")
	}

	if _, free := dp.free[index]; free {
		return errors.New("IP is already free")
	} else {
		dp.free[index] = true
		delete(dp.mac, index)
		return nil
	}
}
131476
func GetFreePort() (int, error) {
	addr, err := net.ResolveTCPAddr("tcp", "localhost:0")
	if err != nil {
		return 0, err
	}

	l, err := net.ListenTCP("tcp", addr)
	if err != nil {
		return 0, err
	}
	defer l.Close()
	return l.Addr().(*net.TCPAddr).Port, nil
}
1363163
func (b *BigIP) GetPool(name string) (*Pool, error) {
	var pool Pool
	err, ok := b.getForEntity(&pool, uriLtm, uriPool, name)
	if err != nil {
		return nil, err
	}
	if !ok {
		return nil, nil
	}

	return &pool, nil
}
754176
func (a *allocator) ReleaseAddress(poolID string, address net.IP) error {
	logrus.Debugf("ReleaseAddress(%s, %v)", poolID, address)
	return nil
}
987803
func (pid *PID) Free() error {
	// If the PID file doesn't exist, just ignore and return.
	if _, err := os.Stat(pid.Path()); os.IsNotExist(err) {
		return nil
	}

	// Delete the PID file
	return os.Remove(pid.Path())
}
813835
func (a *api) RemoveIP(args []string) error {
	client, err := a.connectMaster()
	if err != nil {
		return err
	}

	if err := client.RemoveIPs(args); err != nil {
		return err
	}

	return nil
}
1313203
func (f *FlagSet) IP(name string, value net.IP, usage string) *net.IP {
	p := new(net.IP)
	f.IPVarP(p, name, "", value, usage)
	return p
}
166816
func (_m *API) RemoveVirtualIP(_a0 pool.VirtualIP) error {
	ret := _m.Called(_a0)

	var r0 error
	if rf, ok := ret.Get(0).(func(pool.VirtualIP) error); ok {
		r0 = rf(_a0)
	} else {
		r0 = ret.Error(0)
	}

	return r0
}
1154862
func (n *Network) Free() error {
	var err C.virError
	ret := C.virNetworkFreeWrapper(n.ptr, &err)
	if ret == -1 {
		return makeError(&err)
	}
	return nil
}
515741
func (palette *Palette) Free() {
	C.SDL_FreePalette((*C.SDL_Palette)(unsafe.Pointer(palette)))
}
162892
func (s *IPDirectionalPoolsService) Delete(k IPDirectionalPoolKey) (*http.Response, error) {
	return s.client.delete(k.URI(), nil)
}
828250
func restRemovePoolVirtualIP(w *rest.ResponseWriter, r *rest.Request, ctx *requestContext) {
	ip, err := url.QueryUnescape(r.PathParam("ip"))
	if err != nil {
		glog.Errorf("Could not get virtual ip (%v): %v", ip, err)
		restBadRequest(w, err)
		return
	}

	poolId, err := url.QueryUnescape(r.PathParam("poolId"))
	if err != nil {
		glog.Errorf("Could not get virtual ip poolId (%v): %v", poolId, err)
		restBadRequest(w, err)
		return
	}

	glog.V(0).Infof("Remove virtual ip=%v (in pool %v)", ip, poolId)

	client, err := ctx.getMasterClient()
	if err != nil {
		restServerError(w, err)
		return
	}

	request := pool.VirtualIP{PoolID: poolId, IP: ip}
	if err := client.RemoveVirtualIP(request); err != nil {
		glog.Errorf("Failed to remove virtual IP(%+v): %v", request, err)
		restServerError(w, err)
		return
	}
	restSuccess(w)
}
996886
func (la *Lattice) Free() {
	la.Input = ""
	la.Output = la.Output[:0]
	for i := range la.list {
		for j := range la.list[i] {
			nodePool.Put(la.list[i][j])
		}
		la.list[i] = la.list[i][:0]
	}
	la.list = la.list[:0]
	la.udic = nil
	latticePool.Put(la)
}
1252895
func (c *Context) IP() net.IP {

	var i int
	var s string

	s = "X-Real-IP"
	for i = 0; i < 3; i++ {
		if i == 1 {
			s = strings.ToLower(s)
		}
		if i == 2 {
			s = strings.ToUpper(s)
		}
		if ip := c.Request().Header().Get(s); ip != "" {
			return net.ParseIP(ip)
		}
	}

	s = "X-Forwarded-For"
	for i = 0; i < 3; i++ {
		if i == 1 {
			s = strings.ToLower(s)
		}
		if i == 2 {
			s = strings.ToUpper(s)
		}
		if ip := c.Request().Header().Get(s); ip != "" {
			return net.ParseIP(strings.Split(ip, ", ")[0])
		}
	}

	addr := c.Request().RemoteAddr
	addr, _, _ = net.SplitHostPort(addr)
	return net.ParseIP(addr)

}
879706
func (p *StoragePool) Free() error {
	var err C.virError
	ret := C.virStoragePoolFreeWrapper(p.ptr, &err)
	if ret == -1 {
		return makeError(&err)
	}
	return nil
}
919538
func (c *CIDR) FirstIP() net.IP {
	var ip net.IP
	for ip = IncIP(c.ip.Mask(c.ipnet.Mask)); c.ipnet.Contains(ip); IncIP(ip) {
		break
	}
	return ip
}
886632
func (dp *DHCPPool) IsFreeIPAtIndex(index uint64) bool {
	dp.lock.Lock()
	defer dp.lock.Unlock()

	if !dp.IndexInPool(index) {
		return false
	}

	if _, free := dp.free[index]; free {
		return true
	} else {
		return false
	}
}