Replace assert with NSAssert

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3248 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1998-11-19 21:26:27 +00:00
parent 48a8783482
commit 5777121734
31 changed files with 182 additions and 199 deletions

View file

@ -24,7 +24,6 @@
#include <config.h>
#include <gnustep/base/preface.h>
#include <gnustep/base/Archiver.h>
#include <assert.h>
/* Eventually some functionality may be moved out of Encoder and
Decoder and into these objects.

View file

@ -154,7 +154,7 @@ static id nilBinaryTreeNode;
id tmp;
/* Make sure we actually own the anObject. */
assert ([anObject binaryTree] == self);
NSAssert([anObject binaryTree] == self, NSInternalInconsistencyException);
// here tmp is the right node;
if ((tmp = [anObject rightNode]) != [self nilNode])
@ -179,7 +179,7 @@ static id nilBinaryTreeNode;
id tmp;
/* Make sure we actually own the anObject. */
assert ([anObject binaryTree] == self);
NSAssert([anObject binaryTree] == self, NSInternalInconsistencyException);
// here tmp is the left node;
if ((tmp = [anObject leftNode]) != [self nilNode])
@ -202,7 +202,7 @@ static id nilBinaryTreeNode;
id parentNode;
/* Make sure we actually own the aNode. */
assert ([aNode binaryTree] == self);
NSAssert([aNode binaryTree] == self, NSInternalInconsistencyException);
while ((parentNode = [aNode parentNode]) != [self nilNode])
aNode = parentNode;
@ -215,7 +215,7 @@ static id nilBinaryTreeNode;
unsigned count = 0;
/* Make sure we actually own the aNode. */
assert ([aNode binaryTree] == self);
NSAssert([aNode binaryTree] == self, NSInternalInconsistencyException);
if (aNode == nil || aNode == [self nilNode])
[self error:"in %s, Can't find depth of nil node", sel_get_name(_cmd)];
@ -234,7 +234,7 @@ static id nilBinaryTreeNode;
id tmpNode;
/* Make sure we actually own the aNode. */
assert ([aNode binaryTree] == self);
NSAssert([aNode binaryTree] == self, NSInternalInconsistencyException);
if (aNode == nil || aNode == [self nilNode])
{
@ -262,7 +262,7 @@ static id nilBinaryTreeNode;
unsigned count = 0;
/* Make sure we actually own the aNode. */
assert ([aNode binaryTree] == self);
NSAssert([aNode binaryTree] == self, NSInternalInconsistencyException);
if ([aNode leftNode] != [self nilNode])
count += 1 + [self nodeCountUnderNode:[aNode leftNode]];
@ -276,7 +276,7 @@ static id nilBinaryTreeNode;
id y;
/* Make sure we actually own the aNode. */
assert ([aNode binaryTree] == self);
NSAssert([aNode binaryTree] == self, NSInternalInconsistencyException);
y = [aNode rightNode];
if (y == [self nilNode])
@ -304,7 +304,7 @@ static id nilBinaryTreeNode;
id y;
/* Make sure we actually own the aNode. */
assert ([aNode binaryTree] == self);
NSAssert([aNode binaryTree] == self, NSInternalInconsistencyException);
y = [aNode leftNode];
if (y == [self nilNode])
@ -344,7 +344,7 @@ static id nilBinaryTreeNode;
id theParent, tmpChild;
/* Make sure no one else already owns the newObject. */
assert ([newObject binaryTree] == NO_OBJECT);
NSAssert([newObject binaryTree] == NO_OBJECT, NSInternalInconsistencyException);
/* Claim ownership of the newObject. */
[newObject retain];
@ -386,7 +386,7 @@ static id nilBinaryTreeNode;
id x, y;
/* Make sure we actually own the aNode. */
assert ([oldObject binaryTree] == self);
NSAssert([oldObject binaryTree] == self, NSInternalInconsistencyException);
/* Extract the oldObject and sew up the cut. */
if ([oldObject leftNode] == [self nilNode]
@ -508,7 +508,7 @@ static id nilBinaryTreeNode;
id tmp;
/* Make sure no one else already owns the newObject. */
assert ([newObject linkedList] == NO_OBJECT);
NSAssert([newObject linkedList] == NO_OBJECT, NSInternalInconsistencyException);
/* Claim ownership of the newObject. */
[newObject retain];
@ -542,7 +542,7 @@ static id nilBinaryTreeNode;
id tmp;
/* Make sure no one else already owns the newObject. */
assert ([newObject linkedList] == NO_OBJECT);
NSAssert([newObject linkedList] == NO_OBJECT, NSInternalInconsistencyException);
/* Claim ownership of the newObject. */
[newObject retain];
@ -588,7 +588,7 @@ static id nilBinaryTreeNode;
if (_count == 0)
{
/* Make sure no one else already owns the newObject. */
assert ([newObject linkedList] == NO_OBJECT);
NSAssert([newObject linkedList] == NO_OBJECT, NSInternalInconsistencyException);
/* Claim ownership of the newObject. */
[newObject retain];

View file

@ -48,7 +48,6 @@
#include <Foundation/NSHashTable.h>
#include <Foundation/NSCoder.h>
#include <Foundation/NSAutoreleasePool.h>
#include <assert.h>
/* Exception strings */

View file

@ -686,7 +686,6 @@
array[i++] = o;
}
[self freeEnumState: &es];
assert (c == i);
for (i = 0; i < c; i++)
[array[i] release];
}

View file

@ -30,7 +30,7 @@
#include <gnustep/base/MemoryStream.h>
#include <Foundation/NSConnection.h>
#include <Foundation/NSProxy.h>
#include <assert.h>
#include <Foundation/NSException.h>
#define PTR2LONG(P) (((char*)(P))-(char*)0)
#define LONG2PTR(L) (((char*)0)+(L))
@ -276,14 +276,14 @@ static BOOL debug_connected_coder = NO;
"anObj"s are Proxies! */
if (is_decoding)
{
assert([anObj isProxy]);
assert([anObj targetForProxy] == xref);
NSAssert([anObj isProxy], NSInternalInconsistencyException);
NSAssert([anObj targetForProxy] == xref, NSInternalInconsistencyException);
/* This gets done in Proxy +newForRemote:connection:
[connection addProxy:anObj]; */
}
else
{
assert(PTR2LONG(anObj) == xref);
NSAssert(PTR2LONG(anObj) == xref, NSInternalInconsistencyException);
[connection addLocalObject:anObj];
}
}

View file

@ -618,7 +618,7 @@ my_method_get_next_argument (arglist_t argframe,
/* xxx Perhaps we could speed things up by making this an ivar,
and caching it. */
imp = get_imp (cl, sel);
assert(imp);
NSAssert(imp, NSInternalInconsistencyException);
ret = __builtin_apply((void(*)(void))imp,
argframe,
types_get_size_of_stack_arguments(return_type));

View file

@ -123,7 +123,7 @@
- (void) removeObject: oldObject
{
assert ([oldObject linkedList] == self);
NSAssert([oldObject linkedList] == self, NSInternalInconsistencyException);
if (_first_link == oldObject)
{
if (_count > 1)
@ -152,10 +152,10 @@
- (void) insertObject: newObject after: oldObject
{
/* Make sure we actually own the oldObject. */
assert ([oldObject linkedList] == self);
NSAssert([oldObject linkedList] == self, NSInternalInconsistencyException);
/* Make sure no one else already owns the newObject. */
assert ([newObject linkedList] == NO_OBJECT);
NSAssert([newObject linkedList] == NO_OBJECT, NSInternalInconsistencyException);
/* Claim ownership of the newObject. */
[newObject retain];
@ -185,10 +185,10 @@
- (void) insertObject: newObject before: oldObject
{
/* Make sure we actually own the oldObject. */
assert ([oldObject linkedList] == self);
NSAssert([oldObject linkedList] == self, NSInternalInconsistencyException);
/* Make sure no one else already owns the newObject. */
assert ([newObject linkedList] == NO_OBJECT);
NSAssert([newObject linkedList] == NO_OBJECT, NSInternalInconsistencyException);
/* Claim ownership of the newObject. */
[newObject retain];
@ -218,10 +218,10 @@
- (void) replaceObject: oldObject with: newObject
{
/* Make sure we actually own the oldObject. */
assert ([oldObject linkedList] == self);
NSAssert([oldObject linkedList] == self, NSInternalInconsistencyException);
/* Make sure no one else already owns the newObject. */
assert ([newObject linkedList] == NO_OBJECT);
NSAssert([newObject linkedList] == NO_OBJECT, NSInternalInconsistencyException);
/* Claim ownership of the newObject. */
[newObject retain];
@ -248,7 +248,7 @@
- (void) appendObject: newObject
{
/* Make sure no one else already owns the newObject. */
assert ([newObject linkedList] == NO_OBJECT);
NSAssert([newObject linkedList] == NO_OBJECT, NSInternalInconsistencyException);
/* Insert it. */
if (_count == 0)
@ -271,7 +271,7 @@
- (void) prependObject: newObject
{
/* Make sure no one else already owns the newObject. */
assert ([newObject linkedList] == NO_OBJECT);
NSAssert([newObject linkedList] == NO_OBJECT, NSInternalInconsistencyException);
/* Insert it. */
if (_count == 0)
@ -296,7 +296,7 @@
CHECK_INDEX_RANGE_ERROR(index, (_count+1));
/* Make sure no one else already owns the newObject. */
assert ([newObject linkedList] == NO_OBJECT);
NSAssert([newObject linkedList] == NO_OBJECT, NSInternalInconsistencyException);
/* Insert it. */
if (_count == 0)
@ -356,7 +356,7 @@
- successorOfObject: oldObject
{
/* Make sure we actually own the oldObject. */
assert ([oldObject linkedList] == self);
NSAssert([oldObject linkedList] == self, NSInternalInconsistencyException);
return [oldObject nextLink];
}
@ -364,7 +364,7 @@
- predecessorOfObject: oldObject
{
/* Make sure we actually own the oldObject. */
assert ([oldObject linkedList] == self);
NSAssert([oldObject linkedList] == self, NSInternalInconsistencyException);
return [oldObject prevLink];
}

View file

@ -28,6 +28,7 @@
#include <config.h>
#include <gnustep/base/MachPort.h>
#include <Foundation/NSLock.h>
#include <Foundation/NSException.h>
#include <gnustep/base/Set.h>
#include <mach/cthreads.h>
@ -41,7 +42,7 @@ static NSLock *portDictionaryGate;
+ initialize
{
portDictionaryGate = [NSLock new];
assert(sizeof(int) == sizeof(port_t));
NSAssert(sizeof(int) == sizeof(port_t), NSInternalInconsistencyException);
portDictionary = [[Dictionary alloc]
initWithType:@encode(id)
keyType:@encode(int)];

View file

@ -87,7 +87,6 @@ push_pool_to_cache (struct autorelease_thread_vars *tv, id p)
static id
pop_pool_from_cache (struct autorelease_thread_vars *tv)
{
assert (tv->pool_cache_count);
return tv->pool_cache[--(tv->pool_cache_count)];
}
@ -150,7 +149,6 @@ pop_pool_from_cache (struct autorelease_thread_vars *tv)
- (void) _setChildPool: pool
{
assert (!_child);
_child = pool;
}

View file

@ -39,7 +39,6 @@
#include <Foundation/NSMapTable.h>
#include <Foundation/NSAutoreleasePool.h>
#include <assert.h>
#include <sys/stat.h>
#ifndef __WIN32__
@ -203,7 +202,7 @@ _bundle_path_for_name(NSString* path, NSString* name)
void
_bundle_load_callback(Class theClass, Category *theCategory)
{
assert(_loadingBundle);
NSCAssert(_loadingBundle, NSInternalInconsistencyException);
/* Don't store categories */
if (!theCategory)
[(NSMutableArray *)[_loadingBundle _bundleClasses] addObject: (id)theClass];
@ -266,7 +265,7 @@ _bundle_load_callback(Class theClass, Category *theCategory)
path = [[NSProcessInfo processInfo] processName];
output = objc_find_executable([path cString]);
assert(output);
NSAssert(output, NSInternalInconsistencyException);
path = [NSString stringWithCString: output];
OBJC_FREE(output);

View file

@ -47,7 +47,6 @@
#include <Foundation/NSLock.h>
#include <Foundation/NSThread.h>
#include <Foundation/NSNotification.h>
#include <assert.h>
NSString* NSConnectionReplyMode = @"NSConnectionReplyMode";
@ -1272,7 +1271,7 @@ static int messages_received_count;
this is done is in this function DECODER(). IP will be nil
if mframe_build_return() never called DECODER(), i.e. when
we are just returning (void).*/
assert (ip == (id)-1 || ip == nil);
NSAssert(ip == (id)-1 || ip == nil, NSInternalInconsistencyException);
rep_in_count++; /* received a reply */
return retframe;
}

View file

@ -28,7 +28,6 @@
#include <Foundation/NSArray.h>
#include <Foundation/NSUtilities.h>
#include <Foundation/NSString.h>
#include <assert.h>
@class NSSetNonCore;
@class NSMutableSetNonCore;

View file

@ -32,6 +32,7 @@
#include <Foundation/NSDate.h>
#include <Foundation/NSString.h>
#include <Foundation/NSCoder.h>
#include <Foundation/NSException.h>
#ifndef __WIN32__
#include <time.h>
#endif /* !__WIN32__ */
@ -74,7 +75,7 @@
interval += (double)tp.tv_usec / 1000000.0;
/* There seems to be a problem with bad double arithmetic... */
assert (interval < 0);
NSAssert(interval < 0, NSInternalInconsistencyException);
return interval;
#else

View file

@ -63,7 +63,7 @@ enum
{
NSDistantObject *new_proxy;
assert ([aConnection isValid]);
NSAssert([aConnection isValid], NSInternalInconsistencyException);
if ((new_proxy = [aConnection localForTarget: anObject])) {
return new_proxy;
}
@ -76,7 +76,7 @@ enum
{
NSDistantObject *new_proxy;
assert ([aConnection isValid]);
NSAssert([aConnection isValid], NSInternalInconsistencyException);
if ((new_proxy = [aConnection proxyForTarget: anObject])) {
return new_proxy;
}
@ -121,7 +121,7 @@ enum
format: @"NSDistantObject objects only encode with PortEncoder class"];
encoder_connection = [aRmc connection];
assert (encoder_connection);
NSAssert(encoder_connection, NSInternalInconsistencyException);
if (![encoder_connection isValid])
[NSException
raise: NSGenericException
@ -177,9 +177,9 @@ format: @"NSDistantObject objects only encode with PortEncoder class"];
*/
NSPort *proxy_connection_out_port = [_connection sendPort];
assert (proxy_connection_out_port);
assert ([proxy_connection_out_port isValid]);
assert (proxy_connection_out_port != [encoder_connection sendPort]);
NSAssert(proxy_connection_out_port, NSInternalInconsistencyException);
NSAssert([proxy_connection_out_port isValid], NSInternalInconsistencyException);
NSAssert(proxy_connection_out_port != [encoder_connection sendPort], NSInternalInconsistencyException);
proxy_tag = PROXY_REMOTE_FOR_BOTH;
@ -232,7 +232,7 @@ format: @"NSDistantObject objects only encode with PortEncoder class"];
{
NSDistantObject *new_proxy;
assert ([aConnection isValid]);
NSAssert([aConnection isValid], NSInternalInconsistencyException);
/*
* If there already is a local proxy for this target/connection
@ -268,7 +268,7 @@ format: @"NSDistantObject objects only encode with PortEncoder class"];
{
NSDistantObject *new_proxy;
assert ([aConnection isValid]);
NSAssert([aConnection isValid], NSInternalInconsistencyException);
/*
* If there already is a proxy for this target/connection combination,
@ -395,7 +395,7 @@ static inline BOOL class_is_kind_of (Class self, Class aClassObject)
format: @"NSDistantObject objects only decode with PortDecoder class"];
decoder_connection = [aRmc connection];
assert (decoder_connection);
NSAssert(decoder_connection, NSInternalInconsistencyException);
/* First get the tag, so we know what values need to be decoded. */
[aRmc decodeValueOfCType: @encode(typeof(proxy_tag))
@ -478,7 +478,7 @@ format: @"NSDistantObject objects only decode with PortDecoder class"];
[aRmc decodeObjectAt: &proxy_connection_out_port
withName: NULL];
assert (proxy_connection_out_port);
NSAssert(proxy_connection_out_port, NSInternalInconsistencyException);
/* xxx - if there already exists a connection for talking to the
* out port, we use that one rather than creating a new one from
* our listening port.
@ -508,8 +508,8 @@ format: @"NSDistantObject objects only decode with PortDecoder class"];
NSLog(@"Receiving a triangle-connection proxy 0x%x "
@"connection 0x%x\n", target, (unsigned)proxy_connection);
assert (proxy_connection != decoder_connection);
assert ([proxy_connection isValid]);
NSAssert(proxy_connection != decoder_connection, NSInternalInconsistencyException);
NSAssert([proxy_connection isValid], NSInternalInconsistencyException);
/*
* If we don't already have a proxy for the object on the

View file

@ -113,10 +113,10 @@
[cstream release];
cstream = saved_cstream;
/* Reset ourselves, except for object_2_fref. */
assert (!in_progress_table);
NSAssert(!in_progress_table, NSInternalInconsistencyException);
NSResetMapTable (object_2_xref);
NSResetMapTable (const_ptr_2_xref);
assert (fref_counter == 0);
NSAssert(fref_counter == 0, NSInternalInconsistencyException);
/* Then encode everything "for real". */
[self encodeName: @"Root Object"];

View file

@ -164,8 +164,9 @@
- (unichar) characterAtIndex: (unsigned int)index
{
/* xxx raise NSException instead of assert. */
assert(index < [self length]);
if (index >= [self length])
[NSException raise: NSRangeException
format: @"index greater than sequence length"];
return _contents_chars[index];
}

View file

@ -198,7 +198,7 @@ NSDecrementExtraRefCountWasZero (id anObject)
objc_mutex_unlock (retain_counts_gate);
return YES;
}
assert ((int)(node->value) > 0);
NSAssert((int)(node->value) > 0, NSInternalInconsistencyException);
if (!--((int)(node->value)))
o_map_remove_node (node);
objc_mutex_unlock (retain_counts_gate);

View file

@ -37,7 +37,6 @@
#include <gnustep/base/MemoryStream.h>
#include <Foundation/NSException.h>
#include <Foundation/DistributedObjects.h>
#include <assert.h>
#define DEFAULT_SIZE 256

View file

@ -1040,7 +1040,7 @@ static int debug_run_loop = 0;
id saved_mode;
int num_inputs = 0;
assert (mode);
NSAssert(mode, NSInvalidArgumentException);
saved_mode = _current_mode;
_current_mode = mode;
@ -1209,14 +1209,14 @@ static int debug_run_loop = 0;
if (FD_ISSET (fd_index, &write_fds))
{
id watcher = (id) NSMapGet (wfd_2_object, (void*)fd_index);
assert (watcher);
NSAssert(watcher, NSInternalInconsistencyException);
[watcher eventFor:(void*)fd_index mode:_current_mode];
[NSNotificationQueue runLoopASAP];
}
if (FD_ISSET (fd_index, &read_fds))
{
id watcher = (id) NSMapGet (rfd_2_object, (void*)fd_index);
assert (watcher);
NSAssert(watcher, NSInternalInconsistencyException);
[watcher eventFor:(void*)fd_index mode:_current_mode];
[NSNotificationQueue runLoopASAP];
}

View file

@ -28,7 +28,7 @@
#include <Foundation/NSArray.h>
#include <Foundation/NSUtilities.h>
#include <Foundation/NSString.h>
#include <assert.h>
#include <Foundation/NSException.h>
@interface NSSetNonCore : NSSet
@end
@ -305,9 +305,7 @@ static Class NSMutableSet_concrete_class;
for (i = 0; i < c; i++)
{
k[i] = [e nextObject];
assert(k[i]);
}
assert(![e nextObject]);
return [[[NSArray alloc] initWithObjects:k count:c]
autorelease];
}

View file

@ -26,7 +26,7 @@
#include <Foundation/NSDate.h>
#include <Foundation/NSException.h>
#include <Foundation/NSRunLoop.h>
#include <gnustep/base/Invocation.h>
#include <Foundation/NSInvocation.h>
@implementation NSTimer
@ -121,7 +121,7 @@
{
NSTimeInterval ti = [_fire_date timeIntervalSinceReferenceDate];
NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate];
assert (now < 0.0);
NSAssert(now < 0.0, NSInternalInconsistencyException);
while (ti < now) // xxx remove this
ti += _interval;
[_fire_date release];
@ -131,7 +131,7 @@
- (void) invalidate
{
assert (_is_valid);
NSAssert(_is_valid, NSInternalInconsistencyException);
_is_valid = NO;
}

View file

@ -76,14 +76,12 @@
tested them extensively in multithreaded cases. */
/* Define to turn off assertions. */
#define NDEBUG 1
//#define DEBUG 1
/* Define to turn off NSAssertions. */
#define NS_BLOCK_ASSERTIONS 1
#include <config.h>
#include <gnustep/base/preface.h>
#include <assert.h>
#include <stddef.h>
#include <string.h>
#include <objc/objc-api.h>
@ -288,8 +286,8 @@ chunkNext(ff_block *ptr)
static inline void
chunkMakeLink(ff_block *ptr)
{
assert(!chunkIsInUse(ptr));
assert(!chunkIsLive(ptr));
NSAssert(!chunkIsInUse(ptr), NSInternalInconsistencyException);
NSAssert(!chunkIsLive(ptr), NSInternalInconsistencyException);
(&(chunkNext(ptr)->size))[-1] = chunkSize(ptr);
}
@ -299,8 +297,8 @@ chunkChop(ff_block *ptr, size_t size)
ff_block *remainder;
size_t left = chunkSize(ptr)-size;
assert((chunkSize(ptr) % MINCHUNK) == 0);
assert(chunkSize(ptr) > size);
NSAssert((chunkSize(ptr) % MINCHUNK) == 0, NSInternalInconsistencyException);
NSAssert(chunkSize(ptr) > size, NSInternalInconsistencyException);
remainder = (ff_block*)((void*)ptr+size);
chunkSetSize(remainder, left | PREVUSE);
chunkMakeLink(remainder);
@ -314,12 +312,12 @@ chunkPrev(ff_block *ptr)
size_t offset;
ff_block *prev;
assert(!chunkIsPrevInUse(ptr));
NSAssert(!chunkIsPrevInUse(ptr), NSInternalInconsistencyException);
offset = (&(ptr->size))[-1];
assert(offset > 0 && (offset % MINCHUNK) == 0);
NSAssert(offset > 0 && (offset % MINCHUNK) == 0, NSInternalInconsistencyException);
prev = (ff_block*)((void*)ptr-offset);
assert(chunkSize(prev) == offset);
assert(!chunkIsInUse(prev));
NSAssert(chunkSize(prev) == offset, NSInternalInconsistencyException);
NSAssert(!chunkIsInUse(prev), NSInternalInconsistencyException);
return prev;
}
@ -542,8 +540,8 @@ fmalloc (NSZone *zone, size_t size)
size_buf[i] = size_buf[bufsize];
ptr_buf[i] = ptr_buf[bufsize];
assert(chunkIsInUse(chunkhead));
assert((chunkSize(chunkhead) % MINCHUNK) == 0);
NSAssert(chunkIsInUse(chunkhead), NSInternalInconsistencyException);
NSAssert((chunkSize(chunkhead) % MINCHUNK) == 0, NSInternalInconsistencyException);
}
else
{
@ -574,9 +572,9 @@ fmalloc (NSZone *zone, size_t size)
format: @"Out of memory"];
}
assert(chunkIsInUse(chunkhead));
assert(chunkIsPrevInUse(chunkNext(chunkhead)));
assert((chunkSize(chunkhead) % MINCHUNK) == 0);
NSAssert(chunkIsInUse(chunkhead), NSInternalInconsistencyException);
NSAssert(chunkIsPrevInUse(chunkNext(chunkhead)), NSInternalInconsistencyException);
NSAssert((chunkSize(chunkhead) % MINCHUNK) == 0, NSInternalInconsistencyException);
}
chunkhead->next = (ff_block*)(chunkToPointer(chunkhead)+size);
*((char*)chunkhead->next) = (char)42;
@ -601,15 +599,15 @@ frealloc (NSZone *zone, void *ptr, size_t size)
ff_block *chunkhead, *slack;
void *result;
assert(ptr == NULL || NSZoneFromPointer(ptr) == zone);
NSAssert(ptr == NULL || NSZoneFromPointer(ptr) == zone, NSInternalInconsistencyException);
if (ptr == NULL)
return fmalloc(zone, size);
chunkhead = pointerToChunk(ptr);
objc_mutex_lock(zptr->lock);
realsize = chunkSize(chunkhead);
assert(chunkIsInUse(chunkhead));
assert((realsize % MINCHUNK) == 0);
NSAssert(chunkIsInUse(chunkhead), NSInternalInconsistencyException);
NSAssert((realsize % MINCHUNK) == 0, NSInternalInconsistencyException);
chunkClrLive(chunkhead);
if (chunksize < realsize)
@ -633,7 +631,7 @@ frealloc (NSZone *zone, void *ptr, size_t size)
nextchunk = chunkNext(chunkhead);
nextsize = chunkSize(nextchunk);
assert((nextsize % MINCHUNK) == 0);
NSAssert((nextsize % MINCHUNK) == 0, NSInternalInconsistencyException);
if (!chunkIsInUse(nextchunk) && (nextsize+realsize >= chunksize))
/* Expand to next chunk. */
@ -688,13 +686,13 @@ static void
ffree (NSZone *zone, void *ptr)
{
ff_block *chunk;
assert(NSZoneFromPointer(ptr) == zone);
NSAssert(NSZoneFromPointer(ptr) == zone, NSInternalInconsistencyException);
objc_mutex_lock(((ffree_zone*)zone)->lock);
chunk = pointerToChunk(ptr);
if (chunkIsLive(chunk) == 0)
[NSException raise: NSMallocException
format: @"Attempt to free freed memory"];
assert(*((char*)chunk->next) == (char)42);
NSAssert(*((char*)chunk->next) == (char)42, NSInternalInconsistencyException);
add_buf((ffree_zone*)zone, chunk);
objc_mutex_unlock(((ffree_zone*)zone)->lock);
}
@ -960,7 +958,7 @@ fstats (NSZone *zone)
static inline size_t
segindex (size_t size)
{
assert(size%MINCHUNK == 0);
NSAssert(size%MINCHUNK == 0, NSInternalInconsistencyException);
if (size < CLTOSZ(8))
return size/MINCHUNK;
@ -993,7 +991,7 @@ get_chunk (ffree_zone *zone, size_t size)
ff_block *chunk;
ff_link *link = zone->segheadlist[class];
assert(size%MINCHUNK == 0);
NSAssert(size%MINCHUNK == 0, NSInternalInconsistencyException);
while ((link != NULL) && (chunkSize((ff_block*)link) < size))
link = link->next;
@ -1049,13 +1047,13 @@ get_chunk (ffree_zone *zone, size_t size)
{
ff_block *slack;
assert(class < MAX_SEG);
NSAssert(class < MAX_SEG, NSInternalInconsistencyException);
chunk = (ff_block*)zone->segheadlist[class];
assert(!chunkIsInUse(chunk));
assert(size < chunkSize(chunk));
assert((chunkSize(chunk) % MINCHUNK) == 0);
NSAssert(!chunkIsInUse(chunk), NSInternalInconsistencyException);
NSAssert(size < chunkSize(chunk), NSInternalInconsistencyException);
NSAssert((chunkSize(chunk) % MINCHUNK) == 0, NSInternalInconsistencyException);
take_chunk(zone, chunk);
slack = chunkChop(chunk, size);
@ -1069,10 +1067,10 @@ get_chunk (ffree_zone *zone, size_t size)
chunk = (ff_block*)link;
chunksize = chunkSize(chunk);
assert((chunksize % MINCHUNK) == 0);
assert(!chunkIsInUse(chunk));
assert(chunkIsPrevInUse(chunk));
assert(chunkIsInUse(chunkNext(chunk)));
NSAssert((chunksize % MINCHUNK) == 0, NSInternalInconsistencyException);
NSAssert(!chunkIsInUse(chunk), NSInternalInconsistencyException);
NSAssert(chunkIsPrevInUse(chunk), NSInternalInconsistencyException);
NSAssert(chunkIsInUse(chunkNext(chunk)), NSInternalInconsistencyException);
take_chunk(zone, chunk);
if (chunksize > size)
@ -1086,15 +1084,15 @@ get_chunk (ffree_zone *zone, size_t size)
{
ff_block *nextchunk = chunkNext(chunk);
assert(!chunkIsInUse(chunk));
assert(!chunkIsPrevInUse(nextchunk));
assert(chunksize == size);
NSAssert(!chunkIsInUse(chunk), NSInternalInconsistencyException);
NSAssert(!chunkIsPrevInUse(nextchunk), NSInternalInconsistencyException);
NSAssert(chunksize == size, NSInternalInconsistencyException);
chunkSetInUse(chunk);
chunkSetPrevInUse(nextchunk);
}
}
assert(chunkIsInUse(chunk));
assert(chunkIsPrevInUse(chunkNext(chunk)));
NSAssert(chunkIsInUse(chunk), NSInternalInconsistencyException);
NSAssert(chunkIsPrevInUse(chunkNext(chunk)), NSInternalInconsistencyException);
return chunk;
}
@ -1107,8 +1105,8 @@ take_chunk (ffree_zone *zone, ff_block *chunk)
ff_link *otherlink;
ff_link *links = (ff_link*)chunk;
assert((size % MINCHUNK) == 0);
assert(!chunkIsInUse(chunk));
NSAssert((size % MINCHUNK) == 0, NSInternalInconsistencyException);
NSAssert(!chunkIsInUse(chunk), NSInternalInconsistencyException);
if (links->prev == NULL)
zone->segheadlist[class] = links->next;
@ -1140,15 +1138,15 @@ put_chunk (ffree_zone *zone, ff_block *chunk)
size_t class = segindex(size);
ff_link *links = (ff_link*)chunk;
assert((chunkSize(chunk) % MINCHUNK) == 0);
assert(!chunkIsInUse(chunk));
assert(chunkIsPrevInUse(chunk));
assert(chunkIsInUse(chunkNext(chunk)));
NSAssert((chunkSize(chunk) % MINCHUNK) == 0, NSInternalInconsistencyException);
NSAssert(!chunkIsInUse(chunk), NSInternalInconsistencyException);
NSAssert(chunkIsPrevInUse(chunk), NSInternalInconsistencyException);
NSAssert(chunkIsInUse(chunkNext(chunk)), NSInternalInconsistencyException);
chunkMakeLink(chunk);
if (zone->segtaillist[class] == NULL)
{
assert(zone->segheadlist[class] == NULL);
NSAssert(zone->segheadlist[class] == NULL, NSInternalInconsistencyException);
zone->segheadlist[class] = zone->segtaillist[class] = links;
links->prev = links->next = NULL;
@ -1157,7 +1155,7 @@ put_chunk (ffree_zone *zone, ff_block *chunk)
{
ff_link *prevlink = zone->segtaillist[class];
assert(zone->segheadlist[class] != NULL);
NSAssert(zone->segheadlist[class] != NULL, NSInternalInconsistencyException);
links->next = NULL;
links->prev = prevlink;
@ -1174,10 +1172,10 @@ add_buf (ffree_zone *zone, ff_block *chunk)
{
size_t bufsize = zone->bufsize;
assert(bufsize < BUFFER);
assert(chunkIsInUse(chunk));
assert((chunkSize(chunk) % MINCHUNK) == 0);
assert(chunkSize(chunk) >= MINCHUNK);
NSAssert(bufsize < BUFFER, NSInternalInconsistencyException);
NSAssert(chunkIsInUse(chunk), NSInternalInconsistencyException);
NSAssert((chunkSize(chunk) % MINCHUNK) == 0, NSInternalInconsistencyException);
NSAssert(chunkSize(chunk) >= MINCHUNK, NSInternalInconsistencyException);
zone->bufsize++;
zone->size_buf[bufsize] = chunkSize(chunk);
@ -1197,23 +1195,23 @@ flush_buf (ffree_zone *zone)
size_t *size_buf = zone->size_buf;
ff_block **ptr_buf = zone->ptr_buf;
assert(bufsize <= BUFFER);
NSAssert(bufsize <= BUFFER, NSInternalInconsistencyException);
for (i = 0; i < bufsize; i++)
{
size = size_buf[i];
chunk = ptr_buf[i];
assert(chunkSize(chunk) == size);
assert(chunkIsInUse(chunk));
NSAssert(chunkSize(chunk) == size, NSInternalInconsistencyException);
NSAssert(chunkIsInUse(chunk), NSInternalInconsistencyException);
nextchunk = chunkNext(chunk);
if (!chunkIsPrevInUse(chunk))
/* Coalesce with previous chunk. */
{
chunk = chunkPrev(chunk);
assert(!chunkIsInUse(chunk));
assert(chunkIsPrevInUse(chunk));
NSAssert(!chunkIsInUse(chunk), NSInternalInconsistencyException);
NSAssert(chunkIsPrevInUse(chunk), NSInternalInconsistencyException);
size += chunkSize(chunk);
take_chunk(zone, chunk);
}
@ -1222,8 +1220,8 @@ flush_buf (ffree_zone *zone)
{
size_t nextsize = chunkSize(nextchunk);
assert(chunkIsPrevInUse(nextchunk));
assert((nextsize % MINCHUNK) == 0);
NSAssert(chunkIsPrevInUse(nextchunk), NSInternalInconsistencyException);
NSAssert((nextsize % MINCHUNK) == 0, NSInternalInconsistencyException);
size += nextsize;
take_chunk(zone, nextchunk);
nextchunk = chunkNext(nextchunk);
@ -1231,13 +1229,13 @@ flush_buf (ffree_zone *zone)
chunkSetSize(chunk, size | PREVUSE);
put_chunk(zone, chunk);
chunkClrPrevInUse(nextchunk);
assert(chunkNext(chunk) == nextchunk);
assert(chunkPrev(nextchunk) == chunk);
assert((chunkSize(chunk) % MINCHUNK) == 0);
assert(!chunkIsInUse(chunk));
assert(chunkIsPrevInUse(chunk));
assert(chunkIsInUse(nextchunk));
assert(!chunkIsPrevInUse(nextchunk));
NSAssert(chunkNext(chunk) == nextchunk, NSInternalInconsistencyException);
NSAssert(chunkPrev(nextchunk) == chunk, NSInternalInconsistencyException);
NSAssert((chunkSize(chunk) % MINCHUNK) == 0, NSInternalInconsistencyException);
NSAssert(!chunkIsInUse(chunk), NSInternalInconsistencyException);
NSAssert(chunkIsPrevInUse(chunk), NSInternalInconsistencyException);
NSAssert(chunkIsInUse(nextchunk), NSInternalInconsistencyException);
NSAssert(!chunkIsPrevInUse(nextchunk), NSInternalInconsistencyException);
}
zone->bufsize = 0;
}

View file

@ -410,19 +410,19 @@ static NotificationDispatcher *default_notification_dispatcher = nil;
id nr_object;
LinkedList *mapped_nr_list;
assert ([nr_list firstObject] == nr);
NSAssert([nr_list firstObject] == nr, NSInternalInconsistencyException);
if ((nr_name = [nr notificationName]))
{
mapped_nr_list = NSMapGet (_name_2_nr_list, nr_name);
assert (mapped_nr_list == nr_list);
NSAssert(mapped_nr_list == nr_list, NSInternalInconsistencyException);
NSMapRemove (_name_2_nr_list, nr_name);
}
else
{
nr_object = [nr notificationObject];
assert (nr_object);
NSAssert(nr_object, NSInternalInconsistencyException);
mapped_nr_list = NSMapGet (_object_2_nr_list, nr_object);
assert (mapped_nr_list == nr_list);
NSAssert(mapped_nr_list == nr_list, NSInternalInconsistencyException);
NSMapRemove (_object_2_nr_list, nr_object);
}
}

View file

@ -26,6 +26,7 @@
#include <stdio.h>
#include <gnustep/base/Array.h>
#include <gnustep/base/NSString.h>
#include <Foundation/NSException.h>
@implementation OrderedCollection
@ -86,7 +87,7 @@
{
id o;
assert (aCollection != self);
NSAssert(aCollection != self, NSInvalidArgumentException);
/* xxx Could be more efficient. */
FOR_COLLECTION(aCollection, o)
{
@ -99,7 +100,7 @@
{
id o;
assert (aCollection != self);
NSAssert(aCollection != self, NSInvalidArgumentException);
if ([(id)aCollection conformsTo: @protocol(IndexedCollecting)])
{
FOR_INDEXED_COLLECTION_REVERSE(self, o)

View file

@ -25,6 +25,7 @@
#include <gnustep/base/Port.h>
#include <gnustep/base/Coder.h> /* for Coding protocol in Object category */
#include <gnustep/base/NotificationDispatcher.h>
#include <Foundation/NSException.h>
@implementation Port
@ -113,7 +114,7 @@
- (void) setReceivedPacketInvocation: (id <Invoking>)invocation
{
assert (!_packet_invocation);
NSAssert(!_packet_invocation, NSInternalInconsistencyException);
_packet_invocation = invocation;
}
@ -158,8 +159,8 @@
self = [super initWithCapacity: c prefix: 0];
if (self)
{
assert ([op isValid]);
assert (!ip || [ip isValid]);
NSAssert([op isValid], NSInternalInconsistencyException);
NSAssert(!ip || [ip isValid], NSInternalInconsistencyException);
_reply_out_port = op;
_receiving_in_port = ip;
}
@ -188,7 +189,7 @@
self = [super initWithCapacity: c prefix: [[self class] prefixSize]];
if (self)
{
assert ([ip isValid]);
NSAssert([ip isValid], NSInternalInconsistencyException);
_reply_in_port = ip;
}
return self;

View file

@ -31,8 +31,8 @@
#include <gnustep/base/RNGBerkeley.h>
#include <gnustep/base/Time.h>
#include <gnustep/base/Coder.h>
#include <Foundation/NSException.h>
#include <limits.h>
#include <assert.h>
typedef union {
float f;
@ -57,8 +57,8 @@ static id defaultRNG = nil;
if (self == [Random class])
{
defaultRNG = [RNGBerkeley class];
assert(sizeof(double) == 2 * sizeof(long));
assert(sizeof(float) == sizeof(long));
NSAssert(sizeof(double) == 2 * sizeof(long), NSInternalInconsistencyException);
NSAssert(sizeof(float) == sizeof(long), NSInternalInconsistencyException);
/* Following taken from libg++ */
@ -238,7 +238,7 @@ static id defaultRNG = nil;
result.f = 1.0;
result.i |= ([rng nextRandom] & singleMantissa.u);
result.f -= 1.0;
assert(result.f < 1.0 && result.f >= 0);
NSAssert(result.f < 1.0 && result.f >= 0, NSInternalInconsistencyException);
return result.f;
}
@ -262,7 +262,7 @@ static id defaultRNG = nil;
result.u[0] |= ([rng nextRandom] & doubleMantissa.u[0]);
result.u[1] |= ([rng nextRandom] & doubleMantissa.u[1]);
result.d -= 1.0;
assert(result.d < 1.0 && result.d >= 0);
NSAssert(result.d < 1.0 && result.d >= 0, NSInternalInconsistencyException);
return result.d;
}

View file

@ -24,7 +24,6 @@
#include <config.h>
#include <objc/Storage.h>
#include <gnustep/base/preface.h>
#include <assert.h>
/* memcpy() and memcmp() are gcc builtin's */
/* Deal with bzero: */
@ -129,7 +128,6 @@ static inline void _makeRoomForAnotherIfNecessary(Storage *self)
{
if (self->numElements == self->maxElements)
{
assert(self->maxElements);
self->maxElements *= 2;
self->dataPtr = (void*)
objc_realloc (self->dataPtr, self->maxElements*self->elementSize);

View file

@ -763,7 +763,7 @@ static NSMapTable* port_number_2_port;
don't create a new one, just return the old one. */
if ((p = (id) NSMapGet (port_number_2_port, (void*)((int)n))))
{
assert (p->is_valid);
NSAssert(p->is_valid, NSInternalInconsistencyException);
return [p retain];
}
@ -784,7 +784,7 @@ static NSMapTable* port_number_2_port;
}
/* Register the port object according to its socket. */
assert (!NSMapGet (socket_2_port, (void*)p->_port_socket));
NSAssert(!NSMapGet (socket_2_port, (void*)p->_port_socket), NSInternalInconsistencyException);
NSMapInsert (socket_2_port, (void*)p->_port_socket, p);
/* Give the socket a name using bind() and INADDR_ANY for the
@ -861,7 +861,7 @@ static NSMapTable* port_number_2_port;
strerror(errno)];
}
assert (p->_listening_address.sin_port);
NSAssert(p->_listening_address.sin_port, NSInternalInconsistencyException);
n = ntohs(p->_listening_address.sin_port);
}
@ -885,7 +885,7 @@ static NSMapTable* port_number_2_port;
hp = gethostbyname (hostname);
if (!hp)
[self error: "Could not get address of local host \"%s\"", hostname];
assert (hp);
NSAssert(hp, NSInternalInconsistencyException);
memcpy (&(p->_listening_address.sin_addr), hp->h_addr, hp->h_length);
}
@ -967,7 +967,7 @@ static NSMapTable* port_number_2_port;
- (struct sockaddr_in*) _listeningSockaddr
{
assert (is_valid);
NSAssert(is_valid, NSInternalInconsistencyException);
return &_listening_address;
}
@ -1127,7 +1127,7 @@ static NSMapTable* port_number_2_port;
{
/* No bytes are remaining to be read for this packet;
the packet is complete; return it. */
assert (packet && [packet class]);
NSAssert(packet && [packet class], NSInternalInconsistencyException);
NSMapRemove(_client_sock_2_packet, (void*)fd_index);
if (debug_tcp_port > 1)
NSLog(@"%s: Read from socket %d\n",
@ -1153,7 +1153,7 @@ static NSMapTable* port_number_2_port;
id out_port;
/* Make sure there is enough room in the provided array. */
assert (*count > NSCountMapTable (_client_sock_2_out_port));
NSAssert(*count > NSCountMapTable (_client_sock_2_out_port), NSInternalInconsistencyException);
/* Put in our listening socket. */
*count = 0;
@ -1177,7 +1177,7 @@ static NSMapTable* port_number_2_port;
id arp = [NSAutoreleasePool new];
id packet;
assert(type == ET_RPORT);
NSAssert(type == ET_RPORT, NSInvalidArgumentException);
packet = [self _tryToGetPacketFromReadableFD: (int)extra];
if (packet) {
@ -1203,9 +1203,9 @@ assert(type == ET_RPORT);
{
int s = [p _port_socket];
assert (is_valid);
NSAssert(is_valid, NSInternalInconsistencyException);
/* Make sure it hasn't already been added. */
assert (!NSMapGet (_client_sock_2_out_port, (void*)s));
NSAssert(!NSMapGet (_client_sock_2_out_port, (void*)s), NSInternalInconsistencyException);
/* Add it, and put its socket in the set of file descriptors we poll. */
NSMapInsert (_client_sock_2_out_port, (void*)s, p);
@ -1217,7 +1217,7 @@ assert(type == ET_RPORT);
id packet;
int s = [p _port_socket];
assert (is_valid);
NSAssert(is_valid, NSInternalInconsistencyException);
if (debug_tcp_port)
NSLog(@"%s: Closed connection from\n %@\n",
object_get_class_name (self), [p description]);
@ -1279,7 +1279,7 @@ assert(type == ET_RPORT);
/* This will call [self _invalidateConnectedOutPort: for each. */
[out_ports[i] invalidate];
}
assert (!NSCountMapTable (_client_sock_2_out_port));
NSAssert(!NSCountMapTable (_client_sock_2_out_port), NSInternalInconsistencyException);
/* xxx Perhaps should delay this close() to keep another port from
getting it. This may help Connection invalidation confusion.
@ -1302,7 +1302,6 @@ assert(type == ET_RPORT);
- (void) dealloc
{
[self invalidate];
/* assert that these are empty? */
NSFreeMapTable (_client_sock_2_out_port);
NSFreeMapTable (_client_sock_2_packet);
[super dealloc];
@ -1352,7 +1351,7 @@ assert(type == ET_RPORT);
- (void) encodeWithCoder: aCoder
{
assert (is_valid);
NSAssert(is_valid, NSInternalInconsistencyException);
/* We are actually encoding a "send right" (ala Mach),
not a receive right.
These values must match those expected by [TcpOutPort +newWithCoder] */
@ -1443,7 +1442,7 @@ static NSMapTable *out_port_bag = NULL;
NSMapEnumerator me = NSEnumerateMapTable (out_port_bag);
void *k;
assert (sockaddr);
NSAssert(sockaddr, NSInternalInconsistencyException);
while (NSNextMapEnumeratorPair (&me, &k, (void**)&p))
{
/* xxx Do I need to make sure connectedInPort is the same too? */
@ -1455,7 +1454,7 @@ static NSMapTable *out_port_bag = NULL;
/* Assume that sin_family is equal. Using memcmp() doesn't
work because sin_zero's may differ. */
{
assert (p->is_valid);
NSAssert(p->is_valid, NSInternalInconsistencyException);
return [p retain];
}
}
@ -1470,11 +1469,11 @@ static NSMapTable *out_port_bag = NULL;
ivar. */
if (sock && (p = NSMapGet (socket_2_port, (void*)sock)))
{
assert ([p isKindOfClass: [TcpOutPort class]]);
NSAssert([p isKindOfClass: [TcpOutPort class]], NSInternalInconsistencyException);
if (sockaddr)
{
/* Make sure the address we're setting it to is non-zero. */
assert (sockaddr->sin_port);
NSAssert(sockaddr->sin_port, NSInternalInconsistencyException);
/* See if the _remote_in_port_address is already set */
if (p->_remote_in_port_address.sin_family)
@ -1520,7 +1519,7 @@ static NSMapTable *out_port_bag = NULL;
}
if (p)
{
assert (p->is_valid);
NSAssert(p->is_valid, NSInternalInconsistencyException);
return [p retain];
}
}
@ -1551,7 +1550,7 @@ static NSMapTable *out_port_bag = NULL;
/* Set the port's address. */
if (sockaddr)
{
assert (sockaddr->sin_port);
NSAssert(sockaddr->sin_port, NSInternalInconsistencyException);
memcpy (&(p->_remote_in_port_address), sockaddr, sizeof(*sockaddr));
}
else
@ -1570,7 +1569,7 @@ static NSMapTable *out_port_bag = NULL;
if (!sock) {
int rval;
assert (p->_remote_in_port_address.sin_family);
NSAssert(p->_remote_in_port_address.sin_family, NSInternalInconsistencyException);
if (connect (p->_port_socket,
(struct sockaddr*)&(p->_remote_in_port_address),
@ -1604,7 +1603,7 @@ static NSMapTable *out_port_bag = NULL;
}
/* Put it in the shared socket->port map table. */
assert (!NSMapGet (socket_2_port, (void*)p->_port_socket));
NSAssert(!NSMapGet (socket_2_port, (void*)p->_port_socket), NSInternalInconsistencyException);
NSMapInsert (socket_2_port, (void*)p->_port_socket, p);
/* Put it in TcpOutPort's registry. */
@ -1701,9 +1700,9 @@ static NSMapTable *out_port_bag = NULL;
format: @"[TcpInPort newWithAcceptedSocket:] getsockname(): %s",
strerror(errno)];
}
assert (size == sizeof (struct sockaddr_in));
NSAssert(size == sizeof (struct sockaddr_in), NSInternalInconsistencyException);
/* xxx Perhaps I have to get peer name here!! */
assert (ntohs (addr.sin_port) != [p portNumber]);
NSAssert(ntohs (addr.sin_port) != [p portNumber], NSInternalInconsistencyException);
#elif 0
struct sockaddr_in in_port_address;
c = read (s, &in_port_address, sizeof(struct sockaddr_in));
@ -1723,7 +1722,7 @@ static NSMapTable *out_port_bag = NULL;
{
id reply_port = [packet replyInPort];
assert (is_valid);
NSAssert(is_valid, NSInternalInconsistencyException);
/* If the socket of this TcpOutPort isn't already being polled
for incoming data by a TcpInPort, and if the packet's REPLY_PORT
@ -1858,11 +1857,11 @@ static NSMapTable *out_port_bag = NULL;
- (void) encodeWithCoder: aCoder
{
assert (is_valid);
NSAssert(is_valid, NSInternalInconsistencyException);
[super encodeWithCoder: aCoder];
assert (!_polling_in_port
NSAssert(!_polling_in_port
|| (ntohs (_remote_in_port_address.sin_port)
!= [_polling_in_port portNumber]));
!= [_polling_in_port portNumber]), NSInternalInconsistencyException);
/* Encode these at bytes, not as C-variables, because they are
already in "network byte-order". */
[aCoder encodeBytes: &_remote_in_port_address.sin_port
@ -1948,7 +1947,7 @@ static NSMapTable *out_port_bag = NULL;
/* *size is the number of bytes in the packet, not including
the PREFIX_SIZE-byte header. */
*packet_size = ntohl (*(PREFIX_LENGTH_TYPE*) prefix_buffer);
assert (packet_size);
NSAssert(packet_size, NSInternalInconsistencyException);
/* If the reply address is non-zero, and the TcpOutPort for this socket
doesn't already have its _address ivar set, then set it now. */
@ -2011,7 +2010,7 @@ static NSMapTable *out_port_bag = NULL;
NSLog(@"%s: Write to socket %d\n", object_get_class_name (self), s);
/* Put the packet size in the first four bytes of the packet. */
assert (prefix == PREFIX_SIZE);
NSAssert(prefix == PREFIX_SIZE, NSInternalInconsistencyException);
*(PREFIX_LENGTH_TYPE*)[data mutableBytes] = htonl (eof_position);
/* Put the sockaddr_in for replies in the next bytes of the prefix

View file

@ -29,7 +29,7 @@
#include <gnustep/base/ConnectedCoder.h>
#include <gnustep/base/Array.h>
#include <Foundation/NSLock.h>
#include <assert.h>
#include <Foundation/NSException.h>
#ifndef __WIN32__
#include <unistd.h>
#include <sys/param.h> /* for MAXHOSTNAMELEN */
@ -105,7 +105,7 @@ static NSMapTable *port_number_2_in_port = NULL;
{
UdpInPort* p;
assert (n > IPPORT_USERRESERVED);
NSAssert(n > IPPORT_USERRESERVED, NSInvalidArgumentException);
[udp_port_gate lock];
@ -139,7 +139,7 @@ static NSMapTable *port_number_2_in_port = NULL;
Fix this. Perhaps there is a better way of getting the address
of the local host. */
hp = gethostbyname ("localhost");
assert (hp);
NSAssert(hp, NSInternalInconsistencyException);
/* Use host's address, and not INADDR_ANY, so that went we
encode our _address for a D.O. operation, they get
our unique host address that can identify us across the network. */
@ -172,7 +172,7 @@ static NSMapTable *port_number_2_in_port = NULL;
perror ("[UdpInPort +newForReceivingFromPortNumber] getsockname()");
abort ();
}
assert (p->_address.sin_port);
NSAssert(p->_address.sin_port, NSInternalInconsistencyException);
}
/* Record it in UdpInPort's map table. */
@ -418,7 +418,7 @@ static Array *udp_out_port_array;
id reply_port = [packet replyPort];
int len = [packet streamEofPosition];
assert (len < MAX_PACKET_SIZE);
NSAssert(len < MAX_PACKET_SIZE, NSInternalInconsistencyException);
if ( ! [reply_port isKindOfClass: [UdpInPort class]])
[self error:"Trying to send to a port that is not a UdpInPort"];

View file

@ -51,7 +51,6 @@
#include <config.h>
#include <gnustep/base/preface.h>
#include <gnustep/base/behavior.h>
#include <assert.h>
#include <Foundation/NSException.h>
static int behavior_debug = 0;
@ -80,8 +79,8 @@ behavior_class_add_class (Class class, Class behavior)
{
Class behavior_super_class = class_get_super_class(behavior);
assert(CLS_ISCLASS(class));
assert(CLS_ISCLASS(behavior));
NSCAssert(CLS_ISCLASS(class), NSInvalidArgumentException);
NSCAssert(CLS_ISCLASS(behavior), NSInvalidArgumentException);
__objc_send_initialize(class);
__objc_send_initialize(behavior);
@ -89,7 +88,7 @@ behavior_class_add_class (Class class, Class behavior)
/* If necessary, increase instance_size of CLASS. */
if (class->instance_size < behavior->instance_size)
{
NSCAssert (!class->subclass_list,
NSCAssert(!class->subclass_list,
@"The behavior-addition code wants to increase the\n"
@"instance size of a class, but it cannot because you\n"
@"have subclassed the class. There are two solutions:\n"
@ -255,7 +254,7 @@ class_add_behavior_method_list (Class class, MethodList_t list)
initialize_sel = sel_register_name ("initialize");
/* Passing of a linked list is not allowed. Do multiple calls. */
assert (!list->method_next);
NSCAssert(!list->method_next, NSInvalidArgumentException);
/* Check for duplicates. */
for (i = 0; i < list->method_count; ++i)
@ -327,8 +326,8 @@ search_for_method_in_list (MethodList_t list, SEL op)
static void __objc_send_initialize(Class class)
{
/* This *must* be a class object */
assert(CLS_ISCLASS(class));
assert(!CLS_ISMETA(class));
NSCAssert(CLS_ISCLASS(class), NSInvalidArgumentException);
NSCAssert(!CLS_ISMETA(class), NSInvalidArgumentException);
if (!CLS_ISINITIALIZED(class))
{
@ -384,10 +383,6 @@ __objc_init_protocols (struct objc_protocol_list* protos)
return;
}
#if 0
assert (protos->next == 0); /* only single ones allowed */
#endif
for(i = 0; i < protos->count; i++)
{
struct objc_protocol* aProto = protos->list[i];
@ -450,7 +445,7 @@ check_class_methods(Class class)
Method_t method = &(mlist->method_list[counter]);
IMP imp = sarray_get(class->dtable,
(size_t)method->method_name->sel_id);
assert((imp == method->method_imp));
NSCAssert((imp == method->method_imp), NSInvalidArgumentException);
sarray_at_put_safe (class->dtable,
(sidx) method->method_name->sel_id,
method->method_imp);

View file

@ -34,7 +34,6 @@
#include <Foundation/NSData.h>
#include <Foundation/NSException.h>
#include <stdlib.h>
#include <assert.h>
/* Deal with strrchr: */
#if STDC_HEADERS || HAVE_STRING_H