mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
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:
parent
c03261dd56
commit
af908b993e
16 changed files with 920 additions and 983 deletions
|
@ -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>
|
||||
|
||||
* 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
|
||||
re-write, -awakeAfterUsingCoder: is now called, and NSString is
|
||||
all cleaned up and ready to go. Richard and I will work on fixing
|
||||
|
|
|
@ -109,7 +109,8 @@ extern void _NSRemoveHandler( NSHandler *handler );
|
|||
if( !setjmp(NSLocalHandler.jumpState) ) {
|
||||
|
||||
#define NS_HANDLER _NSRemoveHandler(&NSLocalHandler); } else { \
|
||||
NSException *localException = NSLocalHandler.exception;
|
||||
NSException *localException; \
|
||||
localException = NSLocalHandler.exception;
|
||||
|
||||
#define NS_ENDHANDLER }}
|
||||
|
||||
|
|
|
@ -1,113 +1,80 @@
|
|||
/* NSZone memory management.
|
||||
Copyright (C) 1996, 1997 Free Software Foundation, Inc.
|
||||
/* Zone memory management. -*- Mode: ObjC -*-
|
||||
Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
|
||||
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 library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
|
||||
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.
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
See NSZone.c for additional information. */
|
||||
|
||||
#ifndef __NSZone_h_GNUSTEP_BASE_INCLUDE
|
||||
#define __NSZone_h_GNUSTEP_BASE_INCLUDE
|
||||
|
||||
#include <objc/thr.h>
|
||||
#include <gnustep/base/config.h>
|
||||
|
||||
@class NSString;
|
||||
|
||||
typedef objc_mutex_t ZoneLock;
|
||||
typedef struct _NSZone NSZone;
|
||||
|
||||
struct _NSZone
|
||||
{
|
||||
unsigned granularity;
|
||||
void *(*malloc)(struct _NSZone *zonep, unsigned size);
|
||||
void *(*realloc)(struct _NSZone *zonep, void *ptr, unsigned size);
|
||||
void (*free)(struct _NSZone *zonep, void *ptr);
|
||||
void (*recycle)(struct _NSZone *zonep);
|
||||
ZoneLock lock;
|
||||
NSString *name;
|
||||
void *table, *bblocks;
|
||||
void *sblocks; /* Block with highest address comes first. */
|
||||
/* Functions for zone. */
|
||||
void *(*malloc)(struct _NSZone *zone, size_t size);
|
||||
void *(*realloc)(struct _NSZone *zone, void *ptr, size_t size);
|
||||
void (*free)(struct _NSZone *zone, void *ptr);
|
||||
void (*recycle)(struct _NSZone *zone);
|
||||
|
||||
size_t gran; // Zone granularity
|
||||
objc_mutex_t lock; // Mutex for zone
|
||||
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)
|
||||
{
|
||||
return (zone->malloc)(zone, size);
|
||||
}
|
||||
extern inline NSZone* NSDefaultMallocZone (void)
|
||||
{ return __nszone_private_hidden_default_zone; }
|
||||
|
||||
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)
|
||||
{
|
||||
return (zone->realloc)(zone, pointer, size);
|
||||
}
|
||||
extern inline void* NSZoneMalloc (NSZone *zone, size_t size)
|
||||
{ return (zone->malloc)(zone, size); }
|
||||
|
||||
/* For a non-freeable zone, ALL memory will be returned, regardless
|
||||
of whether there are objects in it that are still in use. */
|
||||
extern inline void NSRecycleZone(NSZone *zone)
|
||||
{
|
||||
(zone->recycle)(zone);
|
||||
}
|
||||
extern void* NSZoneCalloc (NSZone *zone, size_t elems, size_t bytes);
|
||||
|
||||
/* Will do nothing if pointer == NULL. */
|
||||
extern inline void NSZoneFree(NSZone *zone, void *pointer)
|
||||
{
|
||||
(zone->free)(zone, pointer);
|
||||
}
|
||||
extern inline void* NSZoneRealloc (NSZone *zone, void *ptr, size_t size)
|
||||
{ return (zone->realloc)(zone, ptr, size); }
|
||||
|
||||
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 NSString *NSZoneName (NSZone *zone);
|
||||
extern inline NSString* NSZoneName (NSZone *zone)
|
||||
{ return zone->name; }
|
||||
|
||||
/* Debugging Helpers. */
|
||||
|
||||
/* Will print to stdout if this pointer is in the malloc heap, free
|
||||
status, and size. */
|
||||
extern void NSZonePtrInfo(void *ptr);
|
||||
/* Functions not in OpenStep. */
|
||||
extern BOOL NSZoneMemInUse (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 */
|
||||
#endif /* not __NSZone_h_GNUSTEP_BASE_INCLUDE */
|
||||
|
|
|
@ -53,7 +53,6 @@ struct _o_array
|
|||
/* Identifying information. */
|
||||
int magic_number;
|
||||
size_t serial_number;
|
||||
NSZone *zone;
|
||||
NSString *name;
|
||||
const void *extra;
|
||||
o_callbacks_t extra_callbacks;
|
||||
|
|
|
@ -82,7 +82,6 @@ struct _o_hash
|
|||
* And all structures have them in the same order. */
|
||||
int magic_number;
|
||||
size_t serial_number;
|
||||
NSZone *zone;
|
||||
NSString *name;
|
||||
const void *extra;
|
||||
o_callbacks_t extra_callbacks;
|
||||
|
|
|
@ -53,7 +53,6 @@ struct _o_list
|
|||
/* Container identifiers */
|
||||
int magic_number;
|
||||
size_t serial_number;
|
||||
NSZone *zone;
|
||||
NSString *name;
|
||||
const void *extra;
|
||||
o_callbacks_t extra_callbacks;
|
||||
|
|
|
@ -84,7 +84,6 @@ struct _o_map
|
|||
* And all structures have them in the same order. */
|
||||
int magic_number;
|
||||
size_t serial_number;
|
||||
NSZone *zone;
|
||||
NSString *name;
|
||||
const void *extra;
|
||||
o_callbacks_t extra_callbacks;
|
||||
|
|
|
@ -79,7 +79,8 @@ FILE_AUTHORS = \
|
|||
"Georg Tuparev" \
|
||||
"Peter Burka" \
|
||||
"Albin L. Jones" \
|
||||
"Scott Christley"
|
||||
"Scott Christley" \
|
||||
"Luke Howard"
|
||||
|
||||
DYNAMIC_LINKER=@DYNAMIC_LINKER@
|
||||
|
||||
|
@ -457,6 +458,7 @@ include/NSMethodSignature.h \
|
|||
include/NSNotification.h \
|
||||
include/NSObjCRuntime.h \
|
||||
include/NSObject.h \
|
||||
include/NSPage.h \
|
||||
include/NSPathUtilities.h \
|
||||
include/NSProcessInfo.h \
|
||||
include/NSRange.h \
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSThread.h>
|
||||
#include <Foundation/NSZone.h>
|
||||
#include <limits.h>
|
||||
|
||||
/* TODO:
|
||||
|
@ -299,7 +300,7 @@ pop_pool_from_cache (struct autorelease_thread_vars *tv)
|
|||
for (i = 0; i < released->count; i++)
|
||||
{
|
||||
id anObject = released->objects[i];
|
||||
if (object_get_class(anObject) == (void*) 0xdeadface)
|
||||
if (!NSZoneMemInUse(anObject))
|
||||
[NSException
|
||||
raise: NSGenericException
|
||||
format: @"Autoreleasing deallocated object.\n"
|
||||
|
|
|
@ -26,10 +26,6 @@
|
|||
void NSDeallocateObject(NSObject *anObject)
|
||||
{
|
||||
if ((anObject!=nil) && CLS_ISCLASS(((id)anObject)->class_pointer))
|
||||
{
|
||||
NSZone *z = [anObject zone];
|
||||
((id)anObject)->class_pointer = (void*) 0xdeadface;
|
||||
NSZoneFree (z, anObject);
|
||||
}
|
||||
NSZoneFree (NSZoneFromPointer(anObject), anObject);
|
||||
return;
|
||||
}
|
||||
|
|
1749
Source/NSZone.m
1749
Source/NSZone.m
File diff suppressed because it is too large
Load diff
|
@ -281,7 +281,6 @@ stdio_unchar_func(void *s, int c)
|
|||
|
||||
- (void) dealloc
|
||||
{
|
||||
fclose(fp);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
|
|
@ -415,7 +415,7 @@ o_array_alloc_with_zone(NSZone *zone)
|
|||
o_array_t *
|
||||
o_array_alloc(void)
|
||||
{
|
||||
return o_array_alloc_with_zone(0);
|
||||
return o_array_alloc_with_zone(NSDefaultMallocZone());
|
||||
}
|
||||
|
||||
o_array_t *
|
||||
|
|
|
@ -743,7 +743,7 @@ o_hash_alloc_with_zone(NSZone * zone)
|
|||
o_hash_t *
|
||||
o_hash_alloc(void)
|
||||
{
|
||||
return o_hash_alloc_with_zone(0);
|
||||
return o_hash_alloc_with_zone(NSDefaultMallocZone());
|
||||
}
|
||||
|
||||
o_hash_t *
|
||||
|
@ -994,7 +994,7 @@ o_hash_copy_with_zone(o_hash_t *old_hash, NSZone * zone)
|
|||
o_hash_t *
|
||||
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... **/
|
||||
|
|
|
@ -608,7 +608,7 @@ o_list_alloc_with_zone (NSZone *zone)
|
|||
o_list_t *
|
||||
o_list_alloc (void)
|
||||
{
|
||||
return o_list_alloc_with_zone (0);
|
||||
return o_list_alloc_with_zone (NSDefaultMallocZone());
|
||||
}
|
||||
|
||||
o_list_t *
|
||||
|
@ -782,7 +782,7 @@ o_list_at_index_insert_list(o_list_t *base_list,
|
|||
o_list_t *
|
||||
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 *
|
||||
|
|
|
@ -50,7 +50,7 @@ o_@XX@_magic_number(o_@XX@_t *xx)
|
|||
inline NSZone *
|
||||
o_@XX@_zone(o_@XX@_t *xx)
|
||||
{
|
||||
return xx->zone;
|
||||
return NSZoneFromPointer(xx);
|
||||
}
|
||||
|
||||
/** Names... **/
|
||||
|
@ -191,7 +191,6 @@ _o_@XX@_alloc_with_zone(NSZone *zone)
|
|||
_o_@XX@_set_serial_number(xx);
|
||||
xx->magic_number = _OBJECTS_MAGIC_@XX@;
|
||||
xx->name = 0;
|
||||
xx->zone = zone;
|
||||
xx->extra_callbacks = o_callbacks_for_non_owned_void_p;
|
||||
xx->extra = 0;
|
||||
|
||||
|
|
Loading…
Reference in a new issue