Initial revision

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@748 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
mccallum 1996-01-22 22:55:56 +00:00
parent 6bdd79bcb5
commit a22c8553df
7 changed files with 376 additions and 0 deletions

32
+cronscript Executable file
View file

@ -0,0 +1,32 @@
#!/usr/grads/bin/bash
PATH=/u/mccallum/sparc/bin:/usr/grads/bin:/usr/staff/bin:$PATH
snapdate=`date +%y%m%d`
# Make the snapshot
cd /u/mccallum/collection/libobjects
rm -f .snapshot.errs
make snapshot &> .snapshot.errs
# Move it to ftp location
if [ -e libobjects-${snapdate}.tar.gz ]; then
rm -f /home/cayuga/ftp/pub/u/mccallum/libobjects/libobjects-9*
rm -f /home/cayuga/ftp/pub/u/mccallum/libobjects/ChangeLog-9*
mv libobjects-${snapdate}.tar.gz \
/home/cayuga/ftp/pub/u/mccallum/libobjects
cp ChangeLog \
/home/cayuga/ftp/pub/u/mccallum/libobjects/ChangeLog-${snapdate}
gzip -9 /home/cayuga/ftp/pub/u/mccallum/libobjects/ChangeLog-${snapdate}
cp ChangeLog \
/home/cayuga/ftp/pub/u/mccallum/libobjects/ChangeLog-${snapdate}
chmod a+r /home/cayuga/ftp/pub/u/mccallum/libobjects/*
fi
# Send me mail about it
rm -f .snapshot.mail
echo "This automatically generated by libobjects/cronscript" >.snapshot.mail
echo >>.snapshot.mail
ls -l /home/cayuga/ftp/pub/u/mccallum/libobjects/* >>.snapshot.mail
echo >>.snapshot.mail
cat .snapshot.errs >>.snapshot.mail
mail -s "libobjects-${snapdate} snapshot" mccallum < .snapshot.mail

1
+crontab Normal file
View file

@ -0,0 +1 @@
0 1 * * 3 /u/mccallum/collection/libobjects/cronscript

27
+patch.sh Executable file
View file

@ -0,0 +1,27 @@
#!/usr/grads/bin/bash
# Apply a patch and automatically RCS check-in the changed files if
# the patch succeeds.
# Usage: patch.sh -p1 < ~/Mail/inbox/120
cd /u/mccallum/collection/libobjects
touch .patch.timestamp
if patch --batch $*; then
find . -name '*.orig' -exec mv -f {} ../origs \;
rm -f .patched.files
find . -name RCS -prune -o \
\( -newer .patch.timestamp -type f -print \) \
| grep -v .patched.files > .patched.files
echo PATCH SUCCEEDED!
echo Patched files:
cat .patched.files
ci -u -m"Patched from mail. See ChangeLog" \
-t-"Patched from mail. See ChangeLog" \
`cat .patched.files`
else
echo PATCH FAILED!
echo patch.sh: patch failed - reject files are:
find . -newer .patch.timestamp -name '*.rej' -print
exit 1
fi

2
Admin/.cvsignore Normal file
View file

@ -0,0 +1,2 @@
Makefile
tasks

34
Admin/HOWTO-patches Normal file
View file

@ -0,0 +1,34 @@
Directions for creating a libobjects patch
---------------------------------------------------------------
0. Have somewhere an old, pristine version of the libobjects
directory. We'll assume this directory is called "libobjects-old".
1. Have somewhere a new, changed version of the libobjects directory.
We'll assume this directory is called "libobjects", and that it has
the same parent directory as "libobjects-old"
2. cd to the common parent directory of your two libobjects directories.
3. Create the patch with
diff -r -c2 libobjects-old libobjects >my.patch"
4. Add a GNU-style ChangeLog entry to the top of the patch. You can
do this from within emacs using M-x add-change-log-entry.
5. If you want to include a short note of explanation to me
personally, put it at the top, above the ChangeLog entry.
6. Mail the file to mccallum@gnu.ai.mit.edu.
---------------------------------------------------------------
For a beautiful example from Adam Fedor, see the file example.patch.
If you send me multiple patches to the same file between releases of
libobjects, please diff against a version that has your previous patches.
[I just threw these directions together. If you have constructive
suggestions for improving these directions, please send them to me.
mccallum@gnu.ai.mit.edu]

277
Admin/example.patch Normal file
View file

@ -0,0 +1,277 @@
I took the liberty of moving the double_release checking to NSObject from
NSAutoreleasePool, and also improving it a little. This really helped me
find a bug in my own program (one that even NeXT Foundation didn't catch).
Fri Aug 4 13:39:05 1995 Adam Fedor <fedor@mode.colorado.edu>
* src/NSAutoreleasePool.m ([NSAutoreleasePool -addObject:]):
Remove double_release checking. Increment released_count after
setting released array.
([NSAutoreleasePool -dealloc]): Catch release errors.
([NSAutoreleasePool -enableDoubleReleaseCheck:]): Removed method.
* src/NSObject.h ([NSObject -autorelease], [NSObject -release]):
Add double_release checking.
([NSObject +enableDoubleReleaseCheck:]): New method.
* src/Foundation/NSAutoreleasePool.h: Remove
+enableDoubleReleaseCheck:, add +autoreleaseCountForObject:.
* src/Foundation/NSObject.h: Add +enableDoubleReleaseCheck:.
* src/Foundation/objc-load.h: Include objc-api file.
diff -c libobjects/src/NSAutoreleasePool.m:1.2 libobjects/src/NSAutoreleasePool.
m:1.3
*** libobjects/src/NSAutoreleasePool.m:1.2 Fri Aug 4 13:57:13 1995
--- libobjects/src/NSAutoreleasePool.m Fri Aug 4 13:57:13 1995
***************
*** 44,53 ****
`release' message. Memory use grows, and grows, and... */
static BOOL autorelease_enabled = YES;
- /* When this is `YES', every call to addObject, checks to make sure
- isn't being set up to release itself too many times. */
- static BOOL double_release_check_enabled = NO;
-
/* When the released_count gets over this value, we call error:.
In the future, I may change this to raise an exception or call
a function instead. */
--- 44,49 ----
***************
*** 109,132 ****
if (!autorelease_enabled)
return;
- if (double_release_check_enabled)
- {
- unsigned release_count = [[self class] autoreleaseCountForObject:anObj];
- unsigned retain_count = [anObj retainCount];
- if (release_count > retain_count + 1)
- [self error:"Autorelease would release object too many times."];
- }
-
if (released_count >= pool_count_warning_threshhold)
[self error:"AutoreleasePool count threshhold exceeded."];
- released_count++;
if (released_count == released_size)
{
released_size *= 2;
OBJC_REALLOC(released, id, released_size);
}
released[released_count] = anObj;
}
- init
--- 105,120 ----
if (!autorelease_enabled)
return;
if (released_count >= pool_count_warning_threshhold)
[self error:"AutoreleasePool count threshhold exceeded."];
if (released_count == released_size)
{
released_size *= 2;
OBJC_REALLOC(released, id, released_size);
}
released[released_count] = anObj;
+ released_count++;
}
- init
***************
*** 154,166 ****
{
int i;
if (parent)
current_pool = parent;
else
current_pool = [[NSAutoreleasePool alloc] init];
- for (i = 0; i < released_count; i++)
- [released[i] release];
- OBJC_FREE(released);
NSDeallocateObject(self);
}
--- 142,165 ----
{
int i;
+ /* Make debugging easier by checking to see if we already dealloced the
+ object before trying to release it. Also, take the object out of the
+ released list just before releasing it, so if we are doing
+ "double_release_check"ing, then autoreleaseCountForObject: won't find the
+ object we are currently releasing. */
+ for (i = 0; i < released_count; i++)
+ {
+ id anObject = released[i];
+ if (anObject->isa == (void*) 0xdeadface)
+ [self error:"Autoreleasing deallocated object. Debug after setting [NSOb
ject enableDoubleReleaseCheck:YES] to check for release errors."];
+ released[i]=0;
+ [anObject release];
+ }
+ OBJC_FREE(released);
if (parent)
current_pool = parent;
else
current_pool = [[NSAutoreleasePool alloc] init];
NSDeallocateObject(self);
}
***************
*** 173,183 ****
+ (void) enableRelease: (BOOL)enable
{
autorelease_enabled = enable;
- }
-
- + (void) enableDoubleReleaseCheck: (BOOL)enable
- {
- double_release_check_enabled = enable;
}
+ (void) setPoolCountThreshhold: (unsigned)c
--- 172,177 ----
diff -c libobjects/src/NSObject.m:1.1.1.2 libobjects/src/NSObject.m:1.2
*** libobjects/src/NSObject.m:1.1.1.2 Fri Aug 4 13:57:14 1995
--- libobjects/src/NSObject.m Fri Aug 4 13:57:14 1995
***************
*** 49,54 ****
--- 49,58 ----
/* The Class responsible for handling autorelease's */
static id autorelease_class = nil;
+ /* When this is `YES', every call to release/autorelease, checks to make sure
+ isn't being set up to release itself too many times. */
+ static BOOL double_release_check_enabled = NO;
+
BOOL NSShouldRetainWithZone(NSObject *anObject, NSZone *requestedZone)
{
if (!requestedZone || [anObject zone] == requestedZone)
***************
*** 282,287 ****
--- 286,300 ----
- autorelease
{
+ if (double_release_check_enabled)
+ {
+ unsigned release_count;
+ unsigned retain_count = [self retainCount];
+ release_count = [autorelease_class autoreleaseCountForObject:self];
+ if (release_count > retain_count)
+ [self error:"Autorelease would release object too many times."];
+ }
+
[autorelease_class addObject:self];
return self;
}
***************
*** 352,357 ****
--- 365,379 ----
- (oneway void) release
{
+ if (double_release_check_enabled)
+ {
+ unsigned release_count;
+ unsigned retain_count = [self retainCount];
+ release_count = [autorelease_class autoreleaseCountForObject:self];
+ if (release_count > retain_count)
+ [self error:"Release would release object too many times."];
+ }
+
if (NSDecrementExtraRefCountWasZero(self))
[self dealloc];
return;
***************
*** 543,548 ****
--- 565,575 ----
+ (Class) autoreleaseClass
{
return autorelease_class;
+ }
+
+ + (void) enableDoubleReleaseCheck: (BOOL)enable
+ {
+ double_release_check_enabled = enable;
}
- (int)compare:anotherObject;
diff -c libobjects/src/Foundation/NSAutoreleasePool.h:1.3 libobjects/src/Foundat
ion/NSAutoreleasePool.h:1.4
*** libobjects/src/Foundation/NSAutoreleasePool.h:1.3 Fri Aug 4 13:57:17 1995
--- libobjects/src/Foundation/NSAutoreleasePool.h Fri Aug 4 13:57:17 1995
***************
*** 38,45 ****
- (void)addObject: anObject;
+ (void) enableRelease: (BOOL)enable;
- + (void) enableDoubleReleaseCheck: (BOOL)enable;
+ (void) setPoolCountThreshhold: (unsigned)c;
@end
--- 38,45 ----
- (void)addObject: anObject;
+ (void) enableRelease: (BOOL)enable;
+ (void) setPoolCountThreshhold: (unsigned)c;
+ + (unsigned) autoreleaseCountForObject: anObject;
@end
diff -c libobjects/src/Foundation/NSObject.h:1.5 libobjects/src/Foundation/NSObj
ect.h:1.6
*** libobjects/src/Foundation/NSObject.h:1.5 Fri Aug 4 13:57:18 1995
--- libobjects/src/Foundation/NSObject.h Fri Aug 4 13:57:18 1995
***************
*** 140,145 ****
--- 140,146 ----
- shouldNotImplement:(SEL)aSel;
+ (Class) autoreleaseClass;
+ (void) setAutoreleaseClass: (Class)aClass;
+ + (void) enableDoubleReleaseCheck: (BOOL)enable;
- read: (TypedStream*)aStream;
- write: (TypedStream*)aStream;
@end
diff -c libobjects/src/Foundation/objc-load.h:1.6 libobjects/src/Foundation/objc
-load.h:1.7
*** libobjects/src/Foundation/objc-load.h:1.6 Fri Aug 4 13:57:18 1995
--- libobjects/src/Foundation/objc-load.h Fri Aug 4 13:57:19 1995
***************
*** 3,16 ****
Copyright (C) 1993, Adam Fedor.
! $Id$
*/
#ifndef __objc_load_h_INCLUDE
#define __objc_load_h_INCLUDE
#include <stdio.h>
! #include <objc/objc.h>
extern char *objc_executable_location();
--- 3,16 ----
Copyright (C) 1993, Adam Fedor.
! $Id$
*/
#ifndef __objc_load_h_INCLUDE
#define __objc_load_h_INCLUDE
#include <stdio.h>
! #include <objc/objc-api.h>
extern char *objc_executable_location();

3
Admin/volunteers Normal file
View file

@ -0,0 +1,3 @@
The libobjects volunteer list has been moved to:
http://www.cs.rochester.edu/u/mccallum/libobjects/volunteers.html