Prev: Compatibility Up: Implementation
These are the details on the functions that make up the `mmalloc'
`void *mmalloc_attach (int FD, void *BASEADDR);'
Initialize access to a `mmalloc' managed region.
If FD is a valid file descriptor for an open file, then data for
the `mmalloc' managed region is mapped to that file. Otherwise
`/dev/zero' is used and the data will not exist in any filesystem
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 its data is
mapped in and is immediately accessible at the same addresses in
the current process as the process that created the file.
If BASEADDR is not `NULL', the mapping is established starting at
the specified address in the process address space. If BASEADDR
is `NULL', the `mmalloc' package chooses a suitable address at
which to start the mapped region, which will be the value of the
previous mapping if opening an existing file which was previously
built by `mmalloc', or for new files will be a value chosen by
Specifying BASEADDR provides more control over where the regions
start and how big they can be before bumping into existing mapped
regions or future mapped regions.
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
On failure returns `NULL'.
`void *mmalloc_detach (void *MD);'
Terminate access to a `mmalloc' managed region identified by the
descriptor MD, by closing the base file and unmapping all memory
pages associated with the region.
Returns `NULL' on success.
Returns the malloc descriptor on failure, which can subsequently
be used for further action (such as obtaining more information
about the nature of the failure).
`void *mmalloc (void *MD, size_t SIZE);'
Given an `mmalloc' descriptor MD, allocate additional memory of
SIZE bytes in the associated mapped region.
`*mrealloc (void *MD, void *PTR, size_t SIZE);'
Given an `mmalloc' descriptor MD and a pointer to memory
previously allocated by `mmalloc' in PTR, reallocate the memory to
be SIZE bytes long, possibly moving the existing contents of
memory if necessary.
`void *mvalloc (void *MD, size_t SIZE);'
Like `mmalloc' but the resulting memory is aligned on a page
`void mfree (void *MD, void *PTR);'
Given an `mmalloc' descriptor MD and a pointer to memory previously
allocated by `mmalloc' in PTR, free the previously allocated
`int mmalloc_errno (void *MD);'
Given a `mmalloc' descriptor, if the last `mmalloc' operation
failed for some reason due to a system call failure, then returns
the associated `errno'. Returns 0 otherwise. (This function is
not yet implemented).
automatically generated by info2www