strncpy(mdp->magic, MMALLOC_MAGIC, MMALLOC_MAGIC_SIZE);
mdp->headersize = sizeof(mtemp);
mdp->version = MMALLOC_VERSION;
- mdp->morecore = __mmalloc_mmap_morecore;
mdp->fd = fd;
mdp->base = mdp->breakval = mdp->top = baseaddr;
mdp->next_mdesc = NULL;
fails, then close the file descriptor if it was opened by us, and arrange
to return a NULL. */
- if ((mbase = mdp->morecore(mdp, sizeof(mtemp))) != NULL) {
+ if ((mbase = mmorecore(mdp, sizeof(mtemp))) != NULL) {
memcpy(mbase, mdp, sizeof(mtemp));
} else {
THROWF(system_error,0,"morecore failed to get some memory!");
if (__mmalloc_remap_core(&mtemp) == mtemp.base) {
mdp = (struct mdesc *) mtemp.base;
mdp->fd = fd;
- mdp->morecore = __mmalloc_mmap_morecore;
if(!mdp->refcount){
sem_init(&mdp->sem, 1, 1);
mdp->refcount++;
/* 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,
+ if ((mmorecore(&mtemp,
(char *) mtemp.base - (char *) mtemp.breakval)) ==
NULL) {
/* Deallocating failed. Update the original malloc descriptor
#include "mmstats.c"
#include "mrealloc.c"
#include "mvalloc.c"
-#include "mmap-sup.c"
+#include "mmorecore.c"
#include "attach.c"
#include "detach.c"
#include "mm_legacy.c"
void *result;
unsigned long int adj;
- result = mdp->morecore(mdp, size);
+ result = mmorecore(mdp, size);
adj = RESIDUAL(result, BLOCKSIZE);
if (adj != 0) {
adj = BLOCKSIZE - adj;
- mdp->morecore(mdp, adj);
+ mmorecore(mdp, adj);
result = (char *) result + adj;
}
return (result);
}
newinfo = (malloc_info *) align(mdp, newsize * sizeof(malloc_info));
if (newinfo == NULL) {
- mdp->morecore(mdp, -size);
+ mmorecore(mdp, -size);
return (NULL);
}
memset((void *) newinfo, 0, newsize * sizeof(malloc_info));
lastblocks = mdp->heapinfo[block].free.size;
if (mdp->heaplimit != 0 &&
block + lastblocks == mdp->heaplimit &&
- mdp->morecore(mdp, 0) == ADDRESS(block + lastblocks) &&
+ mmorecore(mdp, 0) == ADDRESS(block + lastblocks) &&
(morecore(mdp, (blocks - lastblocks) * BLOCKSIZE)) != NULL) {
/* Which block we are extending (the `final free
block' referred to above) might have changed, if
amount to either add to or subtract from the existing region. Works
like sbrk(), but using mmap(). */
-void *__mmalloc_mmap_morecore(struct mdesc *mdp, int size)
+void *mmorecore(struct mdesc *mdp, int size)
{
ssize_t test = 0;
void *result = NULL;
preserved for future examination. */
int saved_errno;
- /* Pointer to the function that is used to get more core, or return core
- to the system, for requests using this malloc descriptor. For memory
- mapped regions, this is the mmap() based routine. There may also be
- a single malloc descriptor that points to an sbrk() based routine
- for systems without mmap() or for applications that call the mmalloc()
- package with a NULL malloc descriptor.
-
- FIXME: For mapped regions shared by more than one process, this
- needs to be maintained on a per-process basis. */
- void *(*morecore) (struct mdesc * mdp, int size);
-
/* Number of info entries. */
size_t heapsize;
extern void *__mmalloc_remap_core(struct mdesc *mdp);
+/* Get core for the memory region specified by MDP, using SIZE as the
+ amount to either add to or subtract from the existing region. Works
+ like sbrk(), but using mmap(). */
+extern void *mmorecore(struct mdesc *mdp, int size);
+
/* Macro to convert from a user supplied malloc descriptor to pointer to the
internal malloc descriptor. If the user supplied descriptor is NULL, then
use the default internal version, initializing it if necessary. Otherwise