not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include <unistd.h> /* close */
#include <sys/types.h>
#include "mmprivate.h"
/* Now unmap all the pages associated with this region by asking for a
negative increment equal to the current size of the region. */
- if ((mtemp.morecore (&mtemp, mtemp.base - mtemp.breakval)) == NULL)
+ if ((mtemp.morecore (&mtemp, (char*)mtemp.base - (char*)mtemp.breakval)) == NULL)
{
/* Deallocating failed. Update the original malloc descriptor
with any changes */
PTR ptr;
{
int type;
- size_t block, blocks;
+ size_t block;//, blocks; unused variable?
register size_t i;
struct list *prev, *next;
/* Get the address of the first free fragment in this block. */
prev = (struct list *)
- ((PTR) ADDRESS(block) +
- (mdp -> heapinfo[block].busy.info.frag.first << type));
+ ((char*) ADDRESS(block) +
+ ( mdp -> heapinfo[block].busy.info.frag.first << type));
if (mdp -> heapinfo[block].busy.info.frag.nfree ==
(BLOCKSIZE >> type) - 1)
}
}
+
+/* Useless prototype to make gcc happy */
+void free(void* ptr);
+
+
/* When using this package, provide a version of malloc/realloc/free built
on top of it, so that if we use the default sbrk() region we will not
collide with another malloc package trying to do the same thing, if
as inside a system library). */
void
-free (ptr)
- PTR ptr;
+free (PTR ptr)
{
mfree ((PTR) NULL, ptr);
}
{
adj = BLOCKSIZE - adj;
mdp -> morecore (mdp, adj);
- result = (PTR) result + adj;
+ result = (char*) result + adj;
}
return (result);
}
}
/* Check if we need to grow the info table. */
- if ((size_t) BLOCK ((PTR) result + size) > mdp -> heapsize)
+ if ((size_t) BLOCK ((char*) result + size) > mdp -> heapsize)
{
newsize = mdp -> heapsize;
- while ((size_t) BLOCK ((PTR) result + size) > newsize)
+ while ((size_t) BLOCK ((char*) result + size) > newsize)
{
newsize *= 2;
}
mdp -> heapsize = newsize;
}
- mdp -> heaplimit = BLOCK ((PTR) result + size);
+ mdp -> heaplimit = BLOCK ((char*) result + size);
return (result);
}
/* Link all fragments but the first into the free list. */
for (i = 1; i < (size_t) (BLOCKSIZE >> log); ++i)
{
- next = (struct list *) ((PTR) result + (i << log));
+ next = (struct list *) ((char*) result + (i << log));
next -> next = mdp -> fraghead[log].next;
next -> prev = &mdp -> fraghead[log];
next -> prev -> next = next;
#else /* defined(HAVE_MMAP) */
/* Prevent "empty translation unit" warnings from the idiots at X3J11. */
-static char ansi_c_idiots = 69;
+//static char ansi_c_idiots = 69;
#endif /* defined(HAVE_MMAP) */
mdp -> aligned_blocks = l;
}
l -> exact = result;
- result = l -> aligned = (PTR) result + alignment - adj;
+ result = l -> aligned = (char*) result + alignment - adj;
}
}
return (result);
sign of the result is machine dependent for negative values, so force
it to be treated as an unsigned int. */
-#define ADDR2UINT(addr) ((unsigned int) ((PTR) (addr) - (PTR) NULL))
+#define ADDR2UINT(addr) ((unsigned int) ((char*) (addr) - (char*) NULL))
#define RESIDUAL(addr,bsize) ((unsigned int) (ADDR2UINT (addr) % (bsize)))
/* Determine the amount of memory spanned by the initial heap table
/* Address to block number and vice versa. */
-#define BLOCK(A) (((PTR) (A) - mdp -> heapbase) / BLOCKSIZE + 1)
+#define BLOCK(A) (((char*) (A) - (char*) mdp -> heapbase) / BLOCKSIZE + 1)
-#define ADDRESS(B) ((PTR) (((B) - 1) * BLOCKSIZE + mdp -> heapbase))
+#define ADDRESS(B) ((PTR) (((ADDR2UINT(B)) - 1) * BLOCKSIZE + (char*) mdp -> heapbase))
/* Data structure giving per-block information. */
mdp = MD_TO_MDP (md);
result.bytes_total =
- (PTR) mdp -> top - (void *)mdp;
+ (char*) mdp -> top - (char*)mdp;
result.chunks_used = mdp -> heapstats.chunks_used;
result.bytes_used = mdp -> heapstats.bytes_used;
result.chunks_free = mdp -> heapstats.chunks_free;
return (result);
}
+/* Useless prototype to make gcc happy */
+void *realloc (void *ptr, size_t size);
+
/* When using this package, provide a version of malloc/realloc/free built
on top of it, so that if we use the default sbrk() region we will not
collide with another malloc package trying to do the same thing, if
Boston, MA 02111-1307, USA. */
#include "mmprivate.h"
+#include <unistd.h>
/* Cache the pagesize for the current host machine. Note that if the host
does not readily provide a getpagesize() function, we need to emulate it
return (mmemalign (md, cache_pagesize, size));
}
+/* Useless prototype to make gcc happy */
+PTR valloc (size_t size);
PTR
-valloc (size)
- size_t size;
+valloc (size_t size)
{
return mvalloc ((PTR) NULL, size);
}
}
else
{
- mdp -> breakval += size;
- mdp -> top += size;
+ mdp -> breakval = (char*)mdp -> breakval + size;
+ mdp -> top = (char*)mdp -> top + size;
}
return (result);
}