diff options
author | Markus Teich <markus.teich@stusta.mhn.de> | 2016-08-09 12:53:08 +0200 |
---|---|---|
committer | Markus Teich <markus.teich@stusta.mhn.de> | 2016-08-09 12:53:08 +0200 |
commit | f64f620b074bec1bbcca0a5cbc9331ff8c323605 (patch) | |
tree | 4db706ac7b7739fa065dc6c6c336c4c2432c8909 /crypto.c | |
parent | f55d10d5f64d9f859a2693821bacb8da3dd50eb9 (diff) |
use GNUNET_new_array instead of calloc
Diffstat (limited to 'crypto.c')
-rw-r--r-- | crypto.c | 30 |
1 files changed, 13 insertions, 17 deletions
@@ -404,11 +404,7 @@ smc_init1 (uint16_t size1) { gcry_mpi_point_t *ret; - if (NULL == (ret = calloc (size1, sizeof (*ret)))) - { - weprintf ("could not alloc memory for 1 dimensional point array"); - return NULL; - } + ret = GNUNET_new_array (size1, gcry_mpi_point_t); for (uint16_t i = 0; i < size1; i++) { @@ -629,8 +625,8 @@ smc_gen_keyshare (struct BRANDT_Auction *ad, size_t *buflen) brandt_assert (ad && buflen); *buflen = (sizeof (struct ec_mpi) + sizeof (*proof1)); - if (NULL == (ret = calloc (1, *buflen)) || - NULL == (ad->y = smc_init1 (ad->n))) + ret = GNUNET_new_array (*buflen, unsigned char); + if (NULL == (ad->y = smc_init1 (ad->n))) { weprintf ("unable to alloc memory for key shares"); return NULL; @@ -701,8 +697,8 @@ smc_encrypt_bid (struct BRANDT_Auction *ad, size_t *buflen) (sizeof (struct ec_mpi) * 2 + /* alpha, beta */ sizeof (*proof3)) + sizeof (struct proof_2dle)); - if (NULL == (cur = (ret = calloc (1, *buflen))) || - NULL == (ad->alpha = smc_init2 (ad->n, ad->k)) || + cur = ret = GNUNET_new_array (*buflen, unsigned char); + if (NULL == (ad->alpha = smc_init2 (ad->n, ad->k)) || NULL == (ad->beta = smc_init2 (ad->n, ad->k))) { weprintf ("unable to alloc memory for encrypted bids"); @@ -829,8 +825,8 @@ fp_pub_compute_outcome (struct BRANDT_Auction *ad, size_t *buflen) brandt_assert (ad && buflen); *buflen = (ad->k * (sizeof (*gamma) + sizeof (*delta) + sizeof (*proof2))); - if (NULL == (cur = (ret = calloc (1, *buflen))) || - NULL == (ad->gamma2 = smc_init2 (ad->n, ad->k)) || + cur = ret = GNUNET_new_array (*buflen, unsigned char); + if (NULL == (ad->gamma2 = smc_init2 (ad->n, ad->k)) || NULL == (ad->delta2 = smc_init2 (ad->n, ad->k)) || NULL == (ad->tmpa1 = smc_init1 (ad->k)) || NULL == (ad->tmpb1 = smc_init1 (ad->k))) @@ -1018,8 +1014,8 @@ fp_pub_decrypt_outcome (struct BRANDT_Auction *ad, size_t *buflen) brandt_assert (ad && buflen); *buflen = (ad->k * (sizeof (*phi) + sizeof (*proof2))); - if (NULL == (cur = (ret = calloc (1, *buflen))) || - NULL == (ad->phi2 = smc_init2 (ad->n, ad->k))) + cur = ret = GNUNET_new_array (*buflen, unsigned char); + if (NULL == (ad->phi2 = smc_init2 (ad->n, ad->k))) { weprintf ("unable to alloc memory for first price outcome decryption"); return NULL; @@ -1171,8 +1167,8 @@ fp_priv_compute_outcome (struct BRANDT_Auction *ad, size_t *buflen) *buflen = (ad->n * ad->k * /* nk * (gamma, delta, proof2) */ (sizeof (*gamma) + sizeof (*delta) + sizeof (*proof2))); - if (NULL == (cur = (ret = calloc (1, *buflen))) || - NULL == (ad->gamma3 = smc_init3 (ad->n, ad->n, ad->k)) || + cur = ret = GNUNET_new_array (*buflen, unsigned char); + if (NULL == (ad->gamma3 = smc_init3 (ad->n, ad->n, ad->k)) || NULL == (ad->delta3 = smc_init3 (ad->n, ad->n, ad->k))) { weprintf ("unable to alloc memory for first price outcome computation"); @@ -1363,8 +1359,8 @@ fp_priv_decrypt_outcome (struct BRANDT_Auction *ad, size_t *buflen) brandt_assert (ad && buflen); *buflen = (ad->n * ad->k * (sizeof (*phi) + sizeof (*proof2))); - if (NULL == (cur = (ret = calloc (1, *buflen))) || - NULL == (ad->phi3 = smc_init3 (ad->n, ad->n, ad->k))) + cur = ret = GNUNET_new_array (*buflen, unsigned char); + if (NULL == (ad->phi3 = smc_init3 (ad->n, ad->n, ad->k))) { weprintf ("unable to alloc memory for first price outcome decryption"); return NULL; |