1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/Source/GGBUtils.m Fri Mar 07 11:43:02 2008 -0800
1.3 @@ -0,0 +1,38 @@
1.4 +/* Copyright © 2008 Jens Alfke. All Rights Reserved.
1.5 +
1.6 + Redistribution and use in source and binary forms, with or without modification, are permitted
1.7 + provided that the following conditions are met:
1.8 +
1.9 + * Redistributions of source code must retain the above copyright notice, this list of conditions
1.10 + and the following disclaimer.
1.11 + * Redistributions in binary form must reproduce the above copyright notice, this list of
1.12 + conditions and the following disclaimer in the documentation and/or other materials provided
1.13 + with the distribution.
1.14 +
1.15 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
1.16 + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
1.17 + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
1.18 + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1.19 + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
1.20 + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1.21 + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
1.22 + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1.23 +*/
1.24 +#import "GGBUtils.h"
1.25 +
1.26 +
1.27 +void setObj( id *variable, id newValue )
1.28 +{
1.29 + if( *variable != newValue ) {
1.30 + [*variable release];
1.31 + *variable = [newValue retain];
1.32 + }
1.33 +}
1.34 +
1.35 +void setObjCopy( id<NSCopying> *variable, id<NSCopying> newValue )
1.36 +{
1.37 + if( *variable != newValue ) {
1.38 + [*variable release];
1.39 + *variable = [(id)newValue copy];
1.40 + }
1.41 +}