mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-26 10:11:03 +00:00
(NSCreateZone): Call initialize(), so that we won't crash if someone
tries to create an object before main() and before initialize() gets called as a constructor. (NSDefaultMallocZone): Likewise. (initialize): Use a static variable to return immediately if we've been run already. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2042 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
51ec9677bd
commit
4487b20f10
1 changed files with 9 additions and 1 deletions
|
@ -19,6 +19,7 @@
|
|||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
/* This uses some GCC specific extensions. But since the library is
|
||||
supposed to compile on GCC 2.7.2 (patched) or higher, and the only
|
||||
|
@ -355,7 +356,8 @@ NSCreateZone(unsigned startSize, unsigned granularity, BOOL canFree)
|
|||
{
|
||||
NSZone *zone;
|
||||
BlockHeader *block;
|
||||
|
||||
|
||||
initialize ();
|
||||
if ((startSize == 0) || (startSize > maxsblock()))
|
||||
startSize = bsize;
|
||||
else
|
||||
|
@ -403,6 +405,7 @@ NSCreateZone(unsigned startSize, unsigned granularity, BOOL canFree)
|
|||
NSZone*
|
||||
NSDefaultMallocZone(void)
|
||||
{
|
||||
initialize ();
|
||||
return &defaultZone;
|
||||
}
|
||||
|
||||
|
@ -514,8 +517,13 @@ NSMallocCheck(void)
|
|||
static void
|
||||
initialize(void)
|
||||
{
|
||||
static int initialize_done = 0;
|
||||
BlockHeader *block;
|
||||
|
||||
if (initialize_done)
|
||||
return;
|
||||
initialize_done = 1;
|
||||
|
||||
bsize = NSPageSize();
|
||||
zunit = (bsize-sizeof(ZoneTable))/sizeof(NSZone);
|
||||
zonelock = makelock();
|
||||
|
|
Loading…
Reference in a new issue