2005-05-07 H.J. Lu <hongjiu.lu@intel.com>
[deliverable/binutils-gdb.git] / mmalloc / mmemalign.c
index 63350a215cd32abea630467b1a7e1cad927a8a3d..3ada02707d714df25af536b5f684e19d0a490915 100644 (file)
@@ -13,10 +13,10 @@ Library General Public License for more details.
 
 You should have received a copy of the GNU Library General Public
 License along with the GNU C Library; see the file COPYING.LIB.  If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA.  */
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
 
-#include "mmalloc.h"
+#include "mmprivate.h"
 
 PTR
 mmemalign (md, alignment, size)
@@ -29,9 +29,7 @@ mmemalign (md, alignment, size)
   struct alignlist *l;
   struct mdesc *mdp;
 
-  size = ((size + alignment - 1) / alignment) * alignment;
-
-  if ((result = mmalloc (md, size)) != NULL)
+  if ((result = mmalloc (md, size + alignment - 1)) != NULL)
     {
       adj = RESIDUAL (result, alignment);
       if (adj != 0)
@@ -53,11 +51,11 @@ mmemalign (md, alignment, size)
                  mfree (md, result);
                  return (NULL);
                }
+             l -> next = mdp -> aligned_blocks;
+             mdp -> aligned_blocks = l;
            }
          l -> exact = result;
          result = l -> aligned = (char *) result + alignment - adj;
-         l -> next = mdp -> aligned_blocks;
-         mdp -> aligned_blocks = l;
        }
     }
   return (result);
This page took 0.037781 seconds and 4 git commands to generate.