(main): Use new [Coder -closeCoder] method.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@822 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Andrew McCallum 1996-01-25 17:14:29 +00:00
parent f1990b02b2
commit ab2ed86ac1

View file

@ -5,17 +5,22 @@
*/ */
#include <objects/Coder.h> #include <objects/Coder.h>
#include <objects/TextCStream.h>
#include <objects/Set.h> #include <objects/Set.h>
#include <objects/EltNodeCollector.h> #include <objects/EltNodeCollector.h>
#include <objects/LinkedList.h> #include <objects/LinkedList.h>
#include <objects/LinkedListEltNode.h> #include <objects/LinkedListEltNode.h>
#include <objects/NSString.h> #include <objects/NSString.h>
#include <Foundation/NSAutoreleasePool.h>
int main() int main()
{ {
id set, ll; id set, ll;
id coder; id coder;
id name; id name;
id arp;
arp = [[NSAutoreleasePool alloc] init];
/* Create a Set of int's /* Create a Set of int's
and a LinkedList of float's */ and a LinkedList of float's */
@ -41,7 +46,9 @@ int main()
[ll printForDebugger]; [ll printForDebugger];
/* Write them to a file */ /* Write them to a file */
coder = [Coder coderWritingToFile: @"./textcoding.txt"];
coder = [[Coder alloc] initForWritingToFile: @"./textcoding.txt"
withCStreamClass: [TextCStream class]];
[coder encodeObject:set withName:@"Test Set"]; [coder encodeObject:set withName:@"Test Set"];
[coder encodeObject:ll withName:@"Test EltNodeCollector LinkedList"]; [coder encodeObject:ll withName:@"Test EltNodeCollector LinkedList"];
@ -49,7 +56,16 @@ int main()
[set release]; [set release];
[ll release]; [ll release];
/* Close the coder, (and thus flush the stream); then release it.
We must separate the idea of "closing" a stream and
"deallocating" a stream because of delays in deallocation due to
-autorelease. */
[coder closeCoder];
[coder release];
/* Read them back in from the file */ /* Read them back in from the file */
/* First init the stream and coder */ /* First init the stream and coder */
coder = [Coder coderReadingFromFile: @"./textcoding.txt"]; coder = [Coder coderReadingFromFile: @"./textcoding.txt"];
@ -69,5 +85,8 @@ int main()
[set release]; [set release];
[ll release]; [ll release];
/* Do the autorelease. */
[arp release];
exit(0); exit(0);
} }