Copyright 1990, 1991, 1992 Free Software Foundation
Written May 1989 by Mike Haertel.
- Heavily modified Mar 1992 by Fred Fish for mmap'c version.
+ Heavily modified Mar 1992 by Fred Fish for mmap'd version.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
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.
The author may be reached (Email) at the address mike@ai.mit.edu,
or (US mail) as Mike Haertel c/o Free Software Foundation. */
-#include "mmalloc.h"
+#include <string.h> /* Prototypes for memcpy, memmove, memset, etc */
+
+#include "mmprivate.h"
/* Prototypes for local functions */
if (adj != 0)
{
adj = BLOCKSIZE - adj;
- (void) mdp -> morecore (mdp, adj);
+ mdp -> morecore (mdp, adj);
result = (char *) result + adj;
}
return (result);
mdp -> morecore (mdp, -size);
return (NULL);
}
- memset ((PTR)newinfo, 0, newsize * sizeof (malloc_info));
- memcpy ((PTR)newinfo, (PTR)mdp -> heapinfo,
+ memset ((PTR) newinfo, 0, newsize * sizeof (malloc_info));
+ memcpy ((PTR) newinfo, (PTR) mdp -> heapinfo,
mdp -> heapsize * sizeof (malloc_info));
oldinfo = mdp -> heapinfo;
newinfo[BLOCK (oldinfo)].busy.type = 0;
mdp -> morecore (mdp, 0) == ADDRESS(block + lastblocks) &&
(morecore (mdp, (blocks - lastblocks) * BLOCKSIZE)) != NULL)
{
- mdp -> heapinfo[block].free.size = blocks;
+ /* Which block we are extending (the `final free
+ block' referred to above) might have changed, if
+ it got combined with a freed info table. */
+ block = mdp -> heapinfo[0].free.prev;
+
+ mdp -> heapinfo[block].free.size += (blocks - lastblocks);
mdp -> heapstats.bytes_free +=
(blocks - lastblocks) * BLOCKSIZE;
continue;
malloc (size)
size_t size;
{
- return (mmalloc ((void *) NULL, size));
+ PTR result;
+
+ result = mmalloc ((PTR) NULL, size);
+ return (result);
}