If the open file corresponding to FD is from a previous use of
mmalloc and passes some basic sanity checks to ensure that it is
- compatible with the current mmalloc package, then it's data is
+ compatible with the current mmalloc package, then its data is
mapped in and is immediately accessible at the same addresses in
the current process as the process that created the file (ignoring
the BASEADDR parameter).
On success, returns a "malloc descriptor" which is used in subsequent
calls to other mmalloc package functions. It is explicitly "void *"
- ("char *" for systems that don't fully support void) so that users
- of the package don't have to worry about the actual implementation
- details.
+ so that users of the package don't have to worry about the actual
+ implementation details.
On failure returns NULL. */
-void *mmalloc_attach(int fd, void *baseaddr)
+xbt_mheap_t mmalloc_attach(int fd, void *baseaddr)
{
struct mdesc mtemp;
- struct mdesc *mdp;
+ xbt_mheap_t mdp;
void *mbase;
struct stat sbuf;
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!");
mdp->next_mdesc = (struct mdesc *)mbase;
UNLOCK(mdp);
}
-
- return ((void *) mbase);
+
+ return mbase;
}
/* Given an valid file descriptor on an open file, test to see if that file
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++;
}
- if (mdp->mfree_hook != NULL) {
- mmcheckf((void *) mdp, (void (*)(void)) NULL, 1);
- }
}
/* Add the new heap to the linked list of heaps attached by mmalloc */