projects
/
u
/
mdw
/
catacomb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
A variety of small tweaks and fixes. Make mpmont etc. return errors
[u/mdw/catacomb]
/
f-niceprime.c
diff --git
a/f-niceprime.c
b/f-niceprime.c
index
a6191da
..
ce96977
100644
(file)
--- a/
f-niceprime.c
+++ b/
f-niceprime.c
@@
-138,7
+138,7
@@
static const field_ops fops = {
*
* Arguments: @mp *p@ = the characteristic of the field
*
*
* Arguments: @mp *p@ = the characteristic of the field
*
- * Returns: A pointer to the field.
+ * Returns: A pointer to the field
, or null
.
*
* Use: Creates a field structure for a prime field of size %$p$%,
* using efficient reduction for nice primes.
*
* Use: Creates a field structure for a prime field of size %$p$%,
* using efficient reduction for nice primes.
@@
-152,7
+152,10
@@
field *field_niceprime(mp *p)
f->f.one = MP_ONE;
f->f.nbits = mp_bits(p);
f->f.noctets = (f->f.nbits + 7) >> 3;
f->f.one = MP_ONE;
f->f.nbits = mp_bits(p);
f->f.noctets = (f->f.nbits + 7) >> 3;
- mpreduce_create(&f->r, p);
+ if (mpreduce_create(&f->r, p)) {
+ DESTROY(f);
+ return (0);
+ }
f->f.m = f->r.p;
return (&f->f);
}
f->f.m = f->r.p;
return (&f->f);
}