示例#1
0
文件: int.go 项目: locusf/gmp
// Finalizer - release the memory allocated to the mpz
func _Int_finalize(z *Int) {
	if z.init {
		runtime.SetFinalizer(z, nil)
		C.mpz_clear(&z.i[0])
		z.init = false
	}
}
示例#2
0
func (s *scalar) SetInt64(v int64) abstract.Scalar {
	vl := C.long(v)
	if int64(vl) != v {
		panic("Oops, int64 initializer doesn't fit into C.ulong")
	}
	var z C.mpz_t
	C.mpz_init(&z[0])
	C.mpz_set_si(&z[0], vl)
	C.element_set_mpz(&s.e[0], &z[0])
	C.mpz_clear(&z[0])
	return s
}
示例#3
0
func (z *Int) destroy() {
	if z.init {
		C.mpz_clear(&z.i[0])
	}
	z.init = false
}
示例#4
0
文件: int.go 项目: jamesadney/gmp
// Free the space occupied by the underlying gmp object.
func (z *Int) Clear() {
	if z.init {
		C.mpz_clear(z.ptr)
	}
	z.init = false
}