aboutsummaryrefslogtreecommitdiff
path: root/src/math/arg.c
blob: d2eba9bf91014a6291ace8f00925c22708dfb73b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*
 * ecgen, tool for generating Elliptic curve domain parameters
 * Copyright (C) 2017 J08nY
 */
#include "arg.h"

arg_t *arg_new(void) {
	arg_t *arg = pari_malloc(sizeof(arg_t));
	if (!arg) {
		perror("Couldn't malloc.");
		exit(1);
	}
	memset(arg, 0, sizeof(arg_t));
	return arg;
}

void arg_free(arg_t **arg) {
	if (*arg) {
		if ((*arg)->mallocd) {
			pari_free((*arg)->mallocd);
			(*arg)->mallocd = NULL;
		}
		pari_free(*arg);
		*arg = NULL;
	}
}