/* -*-c-*-
*
- * $Id: share.c,v 1.5 2000/12/06 20:30:10 mdw Exp $
+ * $Id: share.c,v 1.6 2001/02/03 16:05:41 mdw Exp $
*
* Shamir's secret sharing
*
/*----- Revision history --------------------------------------------------*
*
* $Log: share.c,v $
+ * Revision 1.6 2001/02/03 16:05:41 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.5 2000/12/06 20:30:10 mdw
* Change secret sharing interface: present the secret at share
* construction time.
/* --- Dispose of the share vector --- */
if (s->v) {
- for (i = 0; i < s->t; i++) {
- if (s->v[i].y)
- mp_drop(s->v[i].y);
- }
+ for (i = 0; i < s->t; i++)
+ mp_drop(s->v[i].y);
xfree(s->v);
}
/* --- Other stuff --- */
- if (s->p)
- mp_drop(s->p);
+ mp_drop(s->p);
}
/* --- @share_mkshares@ --- *
/* --- Various bits of initialization --- */
mp_build(&u, &uw, &uw + 1);
- if (d)
- mp_drop(d);
+ mp_drop(d);
/* --- Evaluate the polynomial at %$x = i + 1$% --- */
}
a = mpbarrett_reduce(&mb, a, a);
- if (m)
- mp_drop(m);
+ mp_drop(m);
mpbarrett_destroy(&mb);
return (a);
}