Example #1
0
File: int.go Project: 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
	}
}
Example #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
}
Example #3
0
func (z *Int) destroy() {
	if z.init {
		C.mpz_clear(&z.i[0])
	}
	z.init = false
}
Example #4
0
// Free the space occupied by the underlying gmp object.
func (z *Int) Clear() {
	if z.init {
		C.mpz_clear(z.ptr)
	}
	z.init = false
}