1 /* Finish access to a mmap'd malloc managed region.
2 Copyright 1992 Free Software Foundation, Inc.
4 Contributed by Fred Fish at Cygnus Support. fnf@cygnus.com
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
24 /* Terminate access to a mmalloc managed region by unmapping all memory pages
25 associated with the region, and closing the file descriptor if it is one
28 Returns NULL on success.
30 Returns the malloc descriptor on failure, which can subsequently be used
31 for further action, such as obtaining more information about the nature of
32 the failure by examining the preserved errno value.
34 Note that the malloc descriptor that we are using is currently located in
35 region we are about to unmap, so we first make a local copy of it on the
36 stack and use the copy. */
47 mtemp
= *(struct mdesc
*) md
;
49 /* Now unmap all the pages associated with this region by asking for a
50 negative increment equal to the current size of the region. */
52 if ((mtemp
.morecore (&mtemp
, mtemp
.base
- mtemp
.top
)) == NULL
)
54 /* Update the original malloc descriptor with any changes */
55 *(struct mdesc
*) md
= mtemp
;
59 if (mtemp
.flags
& MMALLOC_DEVZERO
)
61 (void) close (mtemp
.fd
);
This page took 0.030391 seconds and 4 git commands to generate.