1 /* Support for sbrk() regions.
2 Copyright 1992 Free Software Foundation, Inc.
3 Contributed by Fred Fish at Cygnus Support. fnf@cygnus.com
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20 #include <string.h> /* Prototypes for memcpy, memmove, memset, etc */
26 /* The mmalloc() package can use a single implicit malloc descriptor
27 for mmalloc/mrealloc/mfree operations which do not supply an explicit
28 descriptor. For these operations, sbrk() is used to obtain more core
29 from the system, or return core. This allows mmalloc() to provide
30 backwards compatibility with the non-mmap'd version. */
32 struct mdesc
*__mmalloc_default_mdp
;
34 /* Use sbrk() to get more core. */
37 sbrk_morecore (mdp
, size
)
43 if ((result
= sbrk (size
)) != NULL
)
45 mdp
-> breakval
+= size
;
51 /* Initialize the default malloc descriptor if this is the first time
52 a request has been made to use the default sbrk'd region. */
55 __mmalloc_sbrk_init ()
60 __mmalloc_default_mdp
= (struct mdesc
*) sbrk (sizeof (struct mdesc
));
61 (void) memset ((char *) __mmalloc_default_mdp
, 0, sizeof (struct mdesc
));
62 __mmalloc_default_mdp
-> morecore
= sbrk_morecore
;
63 __mmalloc_default_mdp
-> base
= base
;
64 __mmalloc_default_mdp
-> breakval
= __mmalloc_default_mdp
-> top
= sbrk (0);
65 __mmalloc_default_mdp
-> fd
= -1;
66 return (__mmalloc_default_mdp
);