From 86f261dbc50544d73e4b9ae71fcbc2c6df5b9612 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 7 Apr 1998 18:16:10 +0000 Subject: cipher reorganisiert --- mpi/mpicoder.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'mpi/mpicoder.c') diff --git a/mpi/mpicoder.c b/mpi/mpicoder.c index 4d3f454ac..9362aff65 100644 --- a/mpi/mpicoder.c +++ b/mpi/mpicoder.c @@ -54,8 +54,6 @@ mpi_write( IOBUF out, MPI a ) iobuf_put(out, (nbits) ); p = buf = mpi_get_buffer( a, &n, NULL ); - for( ; !*p && n; p++, n-- ) - ; rc = iobuf_write( out, p, n ); m_free(buf); return rc; @@ -302,6 +300,13 @@ mpi_get_buffer( MPI a, unsigned *nbytes, int *sign ) #error please implement for this limb size. #endif } + + /* this is sub-optimal but we need to do the shift oepration because + * the caller has to free the returned buffer */ + for(p=buffer; !*p && *nbytes; p++, --*nbytes ) + ; + if( p != buffer ) + memmove(buffer,p, *nbytes); return buffer; } -- cgit v1.2.3