[BACK]Return to realloc.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gmp / mpz

Diff for /OpenXM_contrib/gmp/mpz/Attic/realloc.c between version 1.1 and 1.1.1.3

version 1.1, 2000/01/10 15:35:27 version 1.1.1.3, 2003/08/25 16:06:33
Line 1 
Line 1 
 /* _mpz_realloc -- make the mpz_t have NEW_SIZE digits allocated.  /* _mpz_realloc -- make the mpz_t have NEW_ALLOC digits allocated.
   
 Copyright (C) 1991, 1993, 1994, 1995 Free Software Foundation, Inc.  Copyright 1991, 1993, 1994, 1995, 2000, 2001 Free Software Foundation, Inc.
   
 This file is part of the GNU MP Library.  This file is part of the GNU MP Library.
   
 The GNU MP Library is free software; you can redistribute it and/or modify  The GNU MP Library is free software; you can redistribute it and/or modify
 it under the terms of the GNU Library General Public License as published by  it under the terms of the GNU Lesser General Public License as published by
 the Free Software Foundation; either version 2 of the License, or (at your  the Free Software Foundation; either version 2.1 of the License, or (at your
 option) any later version.  option) any later version.
   
 The GNU MP Library is distributed in the hope that it will be useful, but  The GNU MP Library is distributed in the hope that it will be useful, but
 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 License for more details.  License for more details.
   
 You should have received a copy of the GNU Library General Public License  You should have received a copy of the GNU Lesser General Public License
 along with the GNU MP Library; see the file COPYING.LIB.  If not, write to  along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,  the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 MA 02111-1307, USA. */  MA 02111-1307, USA. */
Line 23  MA 02111-1307, USA. */
Line 23  MA 02111-1307, USA. */
 #include "gmp-impl.h"  #include "gmp-impl.h"
   
 void *  void *
 #if __STDC__  _mpz_realloc (mpz_ptr m, mp_size_t new_alloc)
 _mpz_realloc (mpz_ptr m, mp_size_t new_size)  
 #else  
 _mpz_realloc (m, new_size)  
      mpz_ptr m;  
      mp_size_t new_size;  
 #endif  
 {  {
     mp_ptr mp;
   
   /* Never allocate zero space. */    /* Never allocate zero space. */
   if (new_size == 0)    new_alloc = MAX (new_alloc, 1);
     new_size = 1;  
   
   m->_mp_d = (mp_ptr) (*_mp_reallocate_func) (m->_mp_d,    mp = __GMP_REALLOCATE_FUNC_LIMBS (PTR(m), ALLOC(m), new_alloc);
                                               m->_mp_alloc * BYTES_PER_MP_LIMB,    PTR(m) = mp;
                                               new_size * BYTES_PER_MP_LIMB);    ALLOC(m) = new_alloc;
   m->_mp_alloc = new_size;  
   
 #if 0    /* Don't create an invalid number; if the current value doesn't fit after
   /* This might break some code that reads the size field after       reallocation, clear it to 0.  */
      reallocation, in the case the reallocated destination and a    if (ABSIZ(m) > new_alloc)
      source argument are identical.  */      SIZ(m) = 0;
   if (ABS (m->_mp_size) > new_size)  
     m->_mp_size = 0;  
 #endif  
   
   return (void *) m->_mp_d;    return (void *) mp;
 }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.1.3

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>