bn_mp_init.cGo to the documentation of this file.00001 #include <tommath.h> 00002 #ifdef BN_MP_INIT_C 00003 /* LibTomMath, multiple-precision integer library -- Tom St Denis 00004 * 00005 * LibTomMath is a library that provides multiple-precision 00006 * integer arithmetic as well as number theoretic functionality. 00007 * 00008 * The library was designed directly after the MPI library by 00009 * Michael Fromberger but has been written from scratch with 00010 * additional optimizations in place. 00011 * 00012 * The library is free for all purposes without any express 00013 * guarantee it works. 00014 * 00015 * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com 00016 */ 00017 00018 /* init a new mp_int */ 00019 int mp_init (mp_int * a) 00020 { 00021 int i; 00022 00023 /* allocate memory required and clear it */ 00024 a->dp = OPT_CAST(mp_digit) XMALLOC (sizeof (mp_digit) * MP_PREC); 00025 if (a->dp == NULL) { 00026 return MP_MEM; 00027 } 00028 00029 /* set the digits to zero */ 00030 for (i = 0; i < MP_PREC; i++) { 00031 a->dp[i] = 0; 00032 } 00033 00034 /* set the used to zero, allocated digits to the default precision 00035 * and sign to positive */ 00036 a->used = 0; 00037 a->alloc = MP_PREC; 00038 a->sign = MP_ZPOS; 00039 00040 return MP_OKAY; 00041 } 00042 #endif 00043 00044 /* $Source: /cvsroot/tcl/libtommath/bn_mp_init.c,v $ */ 00045 /* $Revision: 1.1.1.3 $ */ 00046 /* $Date: 2006/12/01 00:08:11 $ */
Generated on Wed Mar 12 12:18:24 2008 by 1.5.1 |