Changes by wacko@power1.snu.ac.kr (Yoo C. Chung). See ChangeLog

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2201 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
mccallum 1997-03-03 19:43:25 +00:00
parent b37766bcfb
commit 6aa057e1d8
16 changed files with 920 additions and 983 deletions

View file

@ -1,7 +1,12 @@
Mon Mar 3 14:41:01 1997 Andrew McCallum <mccallum@jprc.com>
* src/NSHost.m, src/include/NSHost.h: New files from Luke Howard
<lukeh@xedoc.com.au>.
Sun Jan 12 13:46:38 1997 Andrew McCallum <mccallum@cs.cmu.edu> Sun Jan 12 13:46:38 1997 Andrew McCallum <mccallum@cs.cmu.edu>
* Version (SUBMINOR_VERSION): Version 0.2.12. There seems to be * Version (SUBMINOR_VERSION): Version 0.2.12. There seems to be
a problem with Richard and my patches to distributed objects, but a problem with Richard's and my patches to distributed objects, but
many other bug fixes have been added, NSZone has a complete many other bug fixes have been added, NSZone has a complete
re-write, -awakeAfterUsingCoder: is now called, and NSString is re-write, -awakeAfterUsingCoder: is now called, and NSString is
all cleaned up and ready to go. Richard and I will work on fixing all cleaned up and ready to go. Richard and I will work on fixing

View file

@ -109,7 +109,8 @@ extern void _NSRemoveHandler( NSHandler *handler );
if( !setjmp(NSLocalHandler.jumpState) ) { if( !setjmp(NSLocalHandler.jumpState) ) {
#define NS_HANDLER _NSRemoveHandler(&NSLocalHandler); } else { \ #define NS_HANDLER _NSRemoveHandler(&NSLocalHandler); } else { \
NSException *localException = NSLocalHandler.exception; NSException *localException; \
localException = NSLocalHandler.exception;
#define NS_ENDHANDLER }} #define NS_ENDHANDLER }}

View file

@ -1,8 +1,8 @@
/* NSZone memory management. /* Zone memory management. -*- Mode: ObjC -*-
Copyright (C) 1996, 1997 Free Software Foundation, Inc. Copyright (C) 1997 Free Software Foundation, Inc.
Written by: Yoo C. Chung <wacko@power1.snu.ac.kr> Written by: Yoo C. Chung <wacko@power1.snu.ac.kr>
Date: September 1996 Date: January 1997
This file is part of the GNUstep Base Library. This file is part of the GNUstep Base Library.
@ -18,96 +18,63 @@
You should have received a copy of the GNU Library General Public You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
See NSZone.c for additional information. */
#ifndef __NSZone_h_GNUSTEP_BASE_INCLUDE #ifndef __NSZone_h_GNUSTEP_BASE_INCLUDE
#define __NSZone_h_GNUSTEP_BASE_INCLUDE #define __NSZone_h_GNUSTEP_BASE_INCLUDE
#include <objc/thr.h> #include <objc/thr.h>
#include <gnustep/base/config.h>
@class NSString; @class NSString;
typedef objc_mutex_t ZoneLock;
typedef struct _NSZone NSZone; typedef struct _NSZone NSZone;
struct _NSZone struct _NSZone
{ {
unsigned granularity; /* Functions for zone. */
void *(*malloc)(struct _NSZone *zonep, unsigned size); void *(*malloc)(struct _NSZone *zone, size_t size);
void *(*realloc)(struct _NSZone *zonep, void *ptr, unsigned size); void *(*realloc)(struct _NSZone *zone, void *ptr, size_t size);
void (*free)(struct _NSZone *zonep, void *ptr); void (*free)(struct _NSZone *zone, void *ptr);
void (*recycle)(struct _NSZone *zonep); void (*recycle)(struct _NSZone *zone);
ZoneLock lock;
NSString *name; size_t gran; // Zone granularity
void *table, *bblocks; objc_mutex_t lock; // Mutex for zone
void *sblocks; /* Block with highest address comes first. */ NSString *name; // Name of zone (default is 'nil')
}; };
/* Create a new zone with its own memory pool.
The library will automatically set the start size and/or the
granularity if STARTSIZE and/or GRANULARITY are zero. Also, there
is no advantage in setting startSize or granularity to multiples of
NSPageSize(). */
extern NSZone*
NSCreateZone(unsigned startSize, unsigned granularity, BOOL canFree);
extern NSZone *NSDefaultMallocZone(void); /* Default zone. Name is hopelessly long so that no one will ever
want to use it. ;) Private variable. */
extern NSZone* __nszone_private_hidden_default_zone;
extern NSZone *NSZoneFromPointer(void *pointer); extern NSZone* NSCreateZone (size_t start, size_t gran, BOOL canFree);
extern inline void *NSZoneMalloc(NSZone *zone, unsigned size) extern inline NSZone* NSDefaultMallocZone (void)
{ { return __nszone_private_hidden_default_zone; }
return (zone->malloc)(zone, size);
}
extern void *NSZoneCalloc(NSZone *zone, unsigned numElems, unsigned numBytes); extern inline NSZone* NSZoneFromPointer (void *ptr)
{ return *((NSZone**)ptr-1); }
extern inline void *NSZoneRealloc(NSZone *zone, void *pointer, unsigned size) extern inline void* NSZoneMalloc (NSZone *zone, size_t size)
{ { return (zone->malloc)(zone, size); }
return (zone->realloc)(zone, pointer, size);
}
/* For a non-freeable zone, ALL memory will be returned, regardless extern void* NSZoneCalloc (NSZone *zone, size_t elems, size_t bytes);
of whether there are objects in it that are still in use. */
extern inline void NSRecycleZone(NSZone *zone)
{
(zone->recycle)(zone);
}
/* Will do nothing if pointer == NULL. */ extern inline void* NSZoneRealloc (NSZone *zone, void *ptr, size_t size)
extern inline void NSZoneFree(NSZone *zone, void *pointer) { return (zone->realloc)(zone, ptr, size); }
{
(zone->free)(zone, pointer); extern inline void NSRecycleZone (NSZone *zone)
} { (zone->recycle)(zone); }
extern inline void NSZoneFree (NSZone *zone, void *ptr)
{ (zone->free)(zone, ptr); }
extern void NSSetZoneName (NSZone *zone, NSString *name); extern void NSSetZoneName (NSZone *zone, NSString *name);
extern NSString *NSZoneName (NSZone *zone); extern inline NSString* NSZoneName (NSZone *zone)
{ return zone->name; }
/* Debugging Helpers. */ /* Functions not in OpenStep. */
extern BOOL NSZoneMemInUse (void *ptr);
/* Will print to stdout if this pointer is in the malloc heap, free #endif /* not __NSZone_h_GNUSTEP_BASE_INCLUDE */
status, and size. */
extern void NSZonePtrInfo(void *ptr);
/* Will verify all internal malloc information.
This is what malloc_debug calls. */
extern BOOL NSMallocCheck(void);
/* Memory-Page-related functions. */
extern unsigned NSPageSize(void);
extern unsigned NSLogPageSize(void);
extern unsigned NSRoundUpToMultipleOfPageSize(unsigned bytes);
extern unsigned NSRoundDownToMultipleOfPageSize(unsigned bytes);
extern unsigned NSRealMemoryAvailable(void);
extern void *NSAllocateMemoryPages(unsigned bytes);
extern void NSDeallocateMemoryPages(void *ptr, unsigned bytes);
extern void NSCopyMemoryPages(const void *source, void *dest, unsigned bytes);
#endif /* __NSZone_h_GNUSTEP_BASE_INCLUDE */

View file

@ -53,7 +53,6 @@ struct _o_array
/* Identifying information. */ /* Identifying information. */
int magic_number; int magic_number;
size_t serial_number; size_t serial_number;
NSZone *zone;
NSString *name; NSString *name;
const void *extra; const void *extra;
o_callbacks_t extra_callbacks; o_callbacks_t extra_callbacks;

View file

@ -82,7 +82,6 @@ struct _o_hash
* And all structures have them in the same order. */ * And all structures have them in the same order. */
int magic_number; int magic_number;
size_t serial_number; size_t serial_number;
NSZone *zone;
NSString *name; NSString *name;
const void *extra; const void *extra;
o_callbacks_t extra_callbacks; o_callbacks_t extra_callbacks;

View file

@ -53,7 +53,6 @@ struct _o_list
/* Container identifiers */ /* Container identifiers */
int magic_number; int magic_number;
size_t serial_number; size_t serial_number;
NSZone *zone;
NSString *name; NSString *name;
const void *extra; const void *extra;
o_callbacks_t extra_callbacks; o_callbacks_t extra_callbacks;

View file

@ -84,7 +84,6 @@ struct _o_map
* And all structures have them in the same order. */ * And all structures have them in the same order. */
int magic_number; int magic_number;
size_t serial_number; size_t serial_number;
NSZone *zone;
NSString *name; NSString *name;
const void *extra; const void *extra;
o_callbacks_t extra_callbacks; o_callbacks_t extra_callbacks;

View file

@ -79,7 +79,8 @@ FILE_AUTHORS = \
"Georg Tuparev" \ "Georg Tuparev" \
"Peter Burka" \ "Peter Burka" \
"Albin L. Jones" \ "Albin L. Jones" \
"Scott Christley" "Scott Christley" \
"Luke Howard"
DYNAMIC_LINKER=@DYNAMIC_LINKER@ DYNAMIC_LINKER=@DYNAMIC_LINKER@
@ -457,6 +458,7 @@ include/NSMethodSignature.h \
include/NSNotification.h \ include/NSNotification.h \
include/NSObjCRuntime.h \ include/NSObjCRuntime.h \
include/NSObject.h \ include/NSObject.h \
include/NSPage.h \
include/NSPathUtilities.h \ include/NSPathUtilities.h \
include/NSProcessInfo.h \ include/NSProcessInfo.h \
include/NSRange.h \ include/NSRange.h \

View file

@ -25,6 +25,7 @@
#include <Foundation/NSAutoreleasePool.h> #include <Foundation/NSAutoreleasePool.h>
#include <Foundation/NSException.h> #include <Foundation/NSException.h>
#include <Foundation/NSThread.h> #include <Foundation/NSThread.h>
#include <Foundation/NSZone.h>
#include <limits.h> #include <limits.h>
/* TODO: /* TODO:
@ -299,7 +300,7 @@ pop_pool_from_cache (struct autorelease_thread_vars *tv)
for (i = 0; i < released->count; i++) for (i = 0; i < released->count; i++)
{ {
id anObject = released->objects[i]; id anObject = released->objects[i];
if (object_get_class(anObject) == (void*) 0xdeadface) if (!NSZoneMemInUse(anObject))
[NSException [NSException
raise: NSGenericException raise: NSGenericException
format: @"Autoreleasing deallocated object.\n" format: @"Autoreleasing deallocated object.\n"

View file

@ -26,10 +26,6 @@
void NSDeallocateObject(NSObject *anObject) void NSDeallocateObject(NSObject *anObject)
{ {
if ((anObject!=nil) && CLS_ISCLASS(((id)anObject)->class_pointer)) if ((anObject!=nil) && CLS_ISCLASS(((id)anObject)->class_pointer))
{ NSZoneFree (NSZoneFromPointer(anObject), anObject);
NSZone *z = [anObject zone];
((id)anObject)->class_pointer = (void*) 0xdeadface;
NSZoneFree (z, anObject);
}
return; return;
} }

File diff suppressed because it is too large Load diff

View file

@ -281,7 +281,6 @@ stdio_unchar_func(void *s, int c)
- (void) dealloc - (void) dealloc
{ {
fclose(fp);
[super dealloc]; [super dealloc];
} }

View file

@ -415,7 +415,7 @@ o_array_alloc_with_zone(NSZone *zone)
o_array_t * o_array_t *
o_array_alloc(void) o_array_alloc(void)
{ {
return o_array_alloc_with_zone(0); return o_array_alloc_with_zone(NSDefaultMallocZone());
} }
o_array_t * o_array_t *

View file

@ -743,7 +743,7 @@ o_hash_alloc_with_zone(NSZone * zone)
o_hash_t * o_hash_t *
o_hash_alloc(void) o_hash_alloc(void)
{ {
return o_hash_alloc_with_zone(0); return o_hash_alloc_with_zone(NSDefaultMallocZone());
} }
o_hash_t * o_hash_t *
@ -994,7 +994,7 @@ o_hash_copy_with_zone(o_hash_t *old_hash, NSZone * zone)
o_hash_t * o_hash_t *
o_hash_copy(o_hash_t *old_hash) o_hash_copy(o_hash_t *old_hash)
{ {
return o_hash_copy_with_zone(old_hash, 0); return o_hash_copy_with_zone(old_hash, NSDefaultMallocZone());
} }
/** Mapping... **/ /** Mapping... **/

View file

@ -608,7 +608,7 @@ o_list_alloc_with_zone (NSZone *zone)
o_list_t * o_list_t *
o_list_alloc (void) o_list_alloc (void)
{ {
return o_list_alloc_with_zone (0); return o_list_alloc_with_zone (NSDefaultMallocZone());
} }
o_list_t * o_list_t *
@ -782,7 +782,7 @@ o_list_at_index_insert_list(o_list_t *base_list,
o_list_t * o_list_t *
o_list_copy (o_list_t *old_list) o_list_copy (o_list_t *old_list)
{ {
return o_list_copy_with_zone (old_list, 0); return o_list_copy_with_zone (old_list, NSDefaultMallocZone());
} }
o_list_t * o_list_t *

View file

@ -50,7 +50,7 @@ o_@XX@_magic_number(o_@XX@_t *xx)
inline NSZone * inline NSZone *
o_@XX@_zone(o_@XX@_t *xx) o_@XX@_zone(o_@XX@_t *xx)
{ {
return xx->zone; return NSZoneFromPointer(xx);
} }
/** Names... **/ /** Names... **/
@ -191,7 +191,6 @@ _o_@XX@_alloc_with_zone(NSZone *zone)
_o_@XX@_set_serial_number(xx); _o_@XX@_set_serial_number(xx);
xx->magic_number = _OBJECTS_MAGIC_@XX@; xx->magic_number = _OBJECTS_MAGIC_@XX@;
xx->name = 0; xx->name = 0;
xx->zone = zone;
xx->extra_callbacks = o_callbacks_for_non_owned_void_p; xx->extra_callbacks = o_callbacks_for_non_owned_void_p;
xx->extra = 0; xx->extra = 0;