diff options
author | Werner Koch <wk@gnupg.org> | 1999-05-04 15:55:41 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 1999-05-04 15:55:41 +0200 |
commit | e5a79b2da81bd01562cd6c469eb106f765f43269 (patch) | |
tree | ca3b24e4356da7c39b95e387566773838e093c93 /mpi | |
parent | See ChangeLog: Thu Apr 29 12:29:22 CEST 1999 Werner Koch (diff) | |
download | gnupg2-e5a79b2da81bd01562cd6c469eb106f765f43269.tar.xz gnupg2-e5a79b2da81bd01562cd6c469eb106f765f43269.zip |
See ChangeLog: Tue May 4 15:49:29 CEST 1999 Werner Koch
Diffstat (limited to 'mpi')
-rw-r--r-- | mpi/ChangeLog | 4 | ||||
-rw-r--r-- | mpi/mpiutil.c | 30 |
2 files changed, 34 insertions, 0 deletions
diff --git a/mpi/ChangeLog b/mpi/ChangeLog index 7d66b809b..10e3bddd6 100644 --- a/mpi/ChangeLog +++ b/mpi/ChangeLog @@ -1,3 +1,7 @@ +Tue May 4 15:47:53 CEST 1999 Werner Koch <wk@isil.d.shuttle.de> + + * mpiutil.c (mpi_alloc_like): New. + Mon Apr 26 17:48:15 CEST 1999 Werner Koch <wk@isil.d.shuttle.de> * mpih-add.c, mpih-sub.c: Removed diff --git a/mpi/mpiutil.c b/mpi/mpiutil.c index 82ba87112..cbbe10d25 100644 --- a/mpi/mpiutil.c +++ b/mpi/mpiutil.c @@ -323,6 +323,36 @@ mpi_copy( MPI a ) } +/**************** + * This function allocates an MPI which is optimized to hold + * a value as large as the one given in the arhgument and allocates it + * with the same flags as A. + */ +MPI +mpi_alloc_like( MPI a ) +{ + MPI b; + + if( a && (a->flags & 4) ) { + void *p = m_is_secure(a->d)? m_alloc_secure( a->nbits ) + : m_alloc( a->nbits ); + memcpy( p, a->d, a->nbits ); + b = mpi_set_opaque( NULL, p, a->nbits ); + } + else if( a ) { + b = mpi_is_secure(a)? mpi_alloc_secure( a->nlimbs ) + : mpi_alloc( a->nlimbs ); + b->nlimbs = 0; + b->sign = 0; + b->flags = a->flags; + b->nbits = 0; + } + else + b = NULL; + return b; +} + + void mpi_set( MPI w, MPI u) { |