Remove duplicate code.
This commit is contained in:
1 parent
3d3e052f23
commit
1befa63c9b
1 file changed
+2
-27
+2
-27
@@ -21,39 +21,14 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <gmp.h> // For testing purpose only.
|
||||
#include "mympz.h"
|
||||
#include "m-string.h"
|
||||
#include "m-list.h"
|
||||
|
||||
static void my_mpz_out_str(FILE *f, const mpz_t z)
|
||||
{
|
||||
mpz_out_str (f, 10, z);
|
||||
}
|
||||
|
||||
static bool my_mpz_in_str(mpz_t z, FILE *f)
|
||||
{
|
||||
return mpz_inp_str (z, f, 10) > 0;
|
||||
}
|
||||
|
||||
static bool my_mpz_equal_p(const mpz_t z1, const mpz_t z2)
|
||||
{
|
||||
return mpz_cmp (z1, z2) == 0;
|
||||
}
|
||||
|
||||
static void my_mpz_str(string_t str, const mpz_t z, bool append)
|
||||
{
|
||||
char *s = mpz_get_str(NULL, 10, z);
|
||||
if (append) string_cat_str (str, s);
|
||||
else string_set_str (str, s);
|
||||
free(s);
|
||||
}
|
||||
|
||||
#include "coverage.h"
|
||||
START_COVERAGE
|
||||
LIST_DEF(list_uint, unsigned int)
|
||||
LIST_DEF(list_mpz, mpz_t, (INIT(mpz_init), INIT_SET(mpz_init_set), SET(mpz_set), CLEAR(mpz_clear), \
|
||||
OUT_STR(my_mpz_out_str), IN_STR(my_mpz_in_str), EQUAL(my_mpz_equal_p), \
|
||||
GET_STR(my_mpz_str)))
|
||||
LIST_DEF(list_mpz, mpz_t, MYMPZ_OPLIST)
|
||||
END_COVERAGE
|
||||
#define LIST_UINT_OPLIST LIST_OPLIST(list_uint)
|
||||
|
||||
|
||||
Reference in new issue
Block a user