Skip to content

Commit

Permalink
Formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
dfaranha committed Feb 3, 2021
1 parent dad7ab7 commit 16f3c55
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions include/relic_bn.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ typedef bn_st *bn_t;
#define bn_new(A) \
A = (bn_t)calloc(1, sizeof(bn_st)); \
if ((A) == NULL) { \
RLC_THROW(ERR_NO_MEMORY); \
RLC_THROW(ERR_NO_MEMORY); \
} \
bn_init(A, RLC_BN_SIZE); \

Expand Down Expand Up @@ -171,7 +171,7 @@ typedef bn_st *bn_t;
#define bn_new_size(A, D) \
A = (bn_t)calloc(1, sizeof(bn_st)); \
if (A == NULL) { \
RLC_THROW(ERR_NO_MEMORY); \
RLC_THROW(ERR_NO_MEMORY); \
} \
bn_init(A, D); \

Expand Down
2 changes: 1 addition & 1 deletion include/relic_eb.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ typedef eb_st *eb_t;
#define eb_new(A) \
A = (eb_t)calloc(1, sizeof(eb_st)); \
if (A == NULL) { \
RLC_THROW(ERR_NO_MEMORY); \
RLC_THROW(ERR_NO_MEMORY); \
} \

#elif ALLOC == AUTO
Expand Down
2 changes: 1 addition & 1 deletion include/relic_ed.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ typedef ed_st *ed_t;
#define ed_new(A) \
A = (ed_t)calloc(1, sizeof(ed_st)); \
if (A == NULL) { \
RLC_THROW(ERR_NO_MEMORY); \
RLC_THROW(ERR_NO_MEMORY); \
}

#elif ALLOC == AUTO
Expand Down
2 changes: 1 addition & 1 deletion include/relic_ep.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ typedef iso_st *iso_t;
#define ep_new(A) \
A = (ep_t)calloc(1, sizeof(ep_st)); \
if (A == NULL) { \
RLC_THROW(ERR_NO_MEMORY); \
RLC_THROW(ERR_NO_MEMORY); \
} \

#elif ALLOC == AUTO
Expand Down
2 changes: 1 addition & 1 deletion include/relic_epx.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ typedef iso2_st *iso2_t;
#define ep2_new(A) \
A = (ep2_t)calloc(1, sizeof(ep2_st)); \
if (A == NULL) { \
RLC_THROW(ERR_NO_MEMORY); \
RLC_THROW(ERR_NO_MEMORY); \
} \
fp2_null((A)->x); \
fp2_null((A)->y); \
Expand Down
18 changes: 10 additions & 8 deletions src/bn/relic_bn_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,15 @@ void bn_grow(bn_t a, int digits) {
}

void bn_trim(bn_t a) {
while (a->used > 0 && a->dp[a->used - 1] == 0) {
--(a->used);
}
/* Zero can't be negative. */
if (a->used <= 0) {
a->used = 1;
a->dp[0] = 0;
a->sign = RLC_POS;
if (a->used <= a->alloc) {
while (a->used > 0 && a->dp[a->used - 1] == 0) {
--(a->used);
}
/* Zero can't be negative. */
if (a->used <= 0) {
a->used = 1;
a->dp[0] = 0;
a->sign = RLC_POS;
}
}
}

0 comments on commit 16f3c55

Please sign in to comment.