it. Note that the macro version @MP_DROP@ doesn't do this.
/* -*-c-*-
*
- * $Id: bbs-rand.c,v 1.3 2000/06/17 10:45:21 mdw Exp $
+ * $Id: bbs-rand.c,v 1.4 2001/02/03 12:00:29 mdw Exp $
*
* Blum-Blum-Shub secure random number generator
*
/*----- Revision history --------------------------------------------------*
*
* $Log: bbs-rand.c,v $
+ * Revision 1.4 2001/02/03 12:00:29 mdw
+ * Now @mp_drop@ checks its argument is non-NULL before attempting to free
+ * it. Note that the macro version @MP_DROP@ doesn't do this.
+ *
* Revision 1.3 2000/06/17 10:45:21 mdw
* Typesetting fixes. Advertise random number generator strength. Use
* secure arena for memory allocation.
void bbs_set(bbs *b, mp *x)
{
- if (b->x)
- mp_drop(b->x);
+ mp_drop(b->x);
b->x = MP_COPY(x);
bbs_step(b);
}
/* -*-c-*-
*
- * $Id: mp-mem.c,v 1.3 2000/06/17 11:45:09 mdw Exp $
+ * $Id: mp-mem.c,v 1.4 2001/02/03 12:00:29 mdw Exp $
*
* Memory management for multiprecision numbers
*
/*----- Revision history --------------------------------------------------*
*
* $Log: mp-mem.c,v $
+ * Revision 1.4 2001/02/03 12:00:29 mdw
+ * Now @mp_drop@ checks its argument is non-NULL before attempting to free
+ * it. Note that the macro version @MP_DROP@ doesn't do this.
+ *
* Revision 1.3 2000/06/17 11:45:09 mdw
* Major memory management overhaul. Added arena support. Use the secure
* arena for secret integers. Replace and improve the MP management macros
* If there are no more references, the integer is destroyed.
*/
-void mp_drop(mp *m) { MP_DROP(m); }
+void mp_drop(mp *m) { if (m) MP_DROP(m); }
/* --- @mp_split@ --- *
*
/* -*-c-*-
*
- * $Id: mp-modsqrt.c,v 1.2 2000/10/08 12:02:21 mdw Exp $
+ * $Id: mp-modsqrt.c,v 1.3 2001/02/03 12:00:29 mdw Exp $
*
* Compute square roots modulo a prime
*
/*----- Revision history --------------------------------------------------*
*
* $Log: mp-modsqrt.c,v $
+ * Revision 1.3 2001/02/03 12:00:29 mdw
+ * Now @mp_drop@ checks its argument is non-NULL before attempting to free
+ * it. Note that the macro version @MP_DROP@ doesn't do this.
+ *
* Revision 1.2 2000/10/08 12:02:21 mdw
* Use @MP_EQ@ instead of @MP_CMP@.
*
/* --- Cope if %$a \not\in Q_p$% --- */
if (mp_jacobi(a, p) != 1) {
- if (d)
- mp_drop(d);
+ mp_drop(d);
return (0);
}
d = mpmont_reduce(&mm, d, r);
mp_drop(ainv);
mp_drop(r); mp_drop(c);
- if (dd)
- mp_drop(dd);
+ mp_drop(dd);
mp_drop(mone);
mpmont_destroy(&mm);
mp_drop(a);
mp_drop(p);
- if (r)
- mp_drop(r);
+ mp_drop(r);
mp_drop(rr);
assert(mparena_count(MPARENA_GLOBAL) == 0);
return (ok);
/* -*-c-*-
*
- * $Id: mp-sqrt.c,v 1.2 2000/10/08 12:02:21 mdw Exp $
+ * $Id: mp-sqrt.c,v 1.3 2001/02/03 12:00:29 mdw Exp $
*
* Compute integer square roots
*
/*----- Revision history --------------------------------------------------*
*
* $Log: mp-sqrt.c,v $
+ * Revision 1.3 2001/02/03 12:00:29 mdw
+ * Now @mp_drop@ checks its argument is non-NULL before attempting to free
+ * it. Note that the macro version @MP_DROP@ doesn't do this.
+ *
* Revision 1.2 2000/10/08 12:02:21 mdw
* Use @MP_EQ@ instead of @MP_CMP@.
*
MP_SHRINK(a);
if (a->v == a->vl) {
- if (d)
- mp_drop(d);
+ mp_drop(d);
return (MP_ZERO);
}
/* --- Finished, at last --- */
mp_drop(q);
- if (r)
- mp_drop(r);
+ mp_drop(r);
return (d);
}
/* -*-c-*-
*
- * $Id: mpmont.c,v 1.12 2000/10/08 15:48:35 mdw Exp $
+ * $Id: mpmont.c,v 1.13 2001/02/03 12:00:29 mdw Exp $
*
* Montgomery reduction
*
/*----- Revision history --------------------------------------------------*
*
* $Log: mpmont.c,v $
+ * Revision 1.13 2001/02/03 12:00:29 mdw
+ * Now @mp_drop@ checks its argument is non-NULL before attempting to free
+ * it. Note that the macro version @MP_DROP@ doesn't do this.
+ *
* Revision 1.12 2000/10/08 15:48:35 mdw
* Rename Karatsuba constants now that we have @gfx_kmul@ too.
*
mp_drop(tab[i]);
xfree(tab);
exit:
- if (d != MP_NEW)
- mp_drop(d);
- if (spare)
- mp_drop(spare);
+ mp_drop(d);
+ mp_drop(spare);
return (x);
}
/* -*-c-*-
*
- * $Id: mpmul.c,v 1.3 2000/10/08 12:11:22 mdw Exp $
+ * $Id: mpmul.c,v 1.4 2001/02/03 12:00:29 mdw Exp $
*
* Multiply many small numbers together
*
/*----- Revision history --------------------------------------------------*
*
* $Log: mpmul.c,v $
+ * Revision 1.4 2001/02/03 12:00:29 mdw
+ * Now @mp_drop@ checks its argument is non-NULL before attempting to free
+ * it. Note that the macro version @MP_DROP@ doesn't do this.
+ *
* Revision 1.3 2000/10/08 12:11:22 mdw
* Use @MP_EQ@ instead of @MP_CMP@.
*
x = mp_fromulong(x, j);
mpmul_add(&b, x);
}
- if (x)
- mp_drop(x);
+ mp_drop(x);
return (mpmul_done(&b));
}