bn_mp_clear.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include <tommath.h>
  2. #include "dbhelpers.h"
  3. #ifdef BN_MP_CLEAR_C
  4. /* LibTomMath, multiple-precision integer library -- Tom St Denis
  5. *
  6. * LibTomMath is a library that provides multiple-precision
  7. * integer arithmetic as well as number theoretic functionality.
  8. *
  9. * The library was designed directly after the MPI library by
  10. * Michael Fromberger but has been written from scratch with
  11. * additional optimizations in place.
  12. *
  13. * The library is free for all purposes without any express
  14. * guarantee it works.
  15. *
  16. * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
  17. */
  18. /* clear one (frees) */
  19. void
  20. mp_clear (mp_int * a)
  21. {
  22. /* only do anything if a hasn't been freed previously */
  23. if (a->dp != NULL) {
  24. /* first zero the digits */
  25. m_burn(a->dp, a->alloc * sizeof(*a->dp));
  26. /* free ram */
  27. XFREE(a->dp);
  28. /* reset members to make debugging easier */
  29. a->dp = NULL;
  30. a->alloc = a->used = 0;
  31. a->sign = MP_ZPOS;
  32. }
  33. }
  34. #endif
  35. /* $Source: /cvs/libtom/libtommath/bn_mp_clear.c,v $ */
  36. /* $Revision: 1.3 $ */
  37. /* $Date: 2006/03/31 14:18:44 $ */