From 4487b20f10e5718069bdee912b9bb8902528c15c Mon Sep 17 00:00:00 2001 From: mccallum Date: Sat, 11 Jan 1997 21:39:38 +0000 Subject: [PATCH] (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 --- Source/NSZone.m | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/NSZone.m b/Source/NSZone.m index 9c8f0d341..5a7fe0931 100644 --- a/Source/NSZone.m +++ b/Source/NSZone.m @@ -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();