Put autorelease pools in place

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3038 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1998-10-07 20:06:56 +00:00
parent e1cbc4c0a2
commit dd21d4651b
4 changed files with 71 additions and 2 deletions

View file

@ -27,11 +27,13 @@
#include <Foundation/NSProcessInfo.h>
#include <Foundation/NSUserDefaults.h>
#include <Foundation/NSDebug.h>
#include <Foundation/NSAutoreleasePool.h>
int
main(int argc, char** argv)
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSUserDefaults *defs;
NSProcessInfo *proc;
NSArray *args;
@ -47,6 +49,7 @@ main(int argc, char** argv)
proc = [NSProcessInfo processInfo];
if (proc == nil) {
NSLog(@"defaults: unable to get process information!\n");
[pool release];
exit(0);
}
@ -103,6 +106,7 @@ main(int argc, char** argv)
printf(
"defaults help\n"
" list options fo the defaults command.\n\n");
[pool release];
exit(0);
}
else if ([[args objectAtIndex: i] isEqual: @"plist"]) {
@ -154,6 +158,7 @@ property list which is set as the value of a default.\n\n");
" );\n"
" Checksum = <01014b5b 123a8b20>\n"
"}'\n\n");
[pool release];
exit(0);
}
}
@ -161,6 +166,7 @@ property list which is set as the value of a default.\n\n");
i = 0;
if ([args count] <= i) {
NSLog(@"defaults: too few arguments supplied!\n");
[pool release];
exit(0);
}
if ([[args objectAtIndex: i] isEqual: @"-u"]) {
@ -169,6 +175,7 @@ property list which is set as the value of a default.\n\n");
}
else {
NSLog(@"defaults: no name supplied for -u option!\n");
[pool release];
exit(0);
}
}
@ -180,6 +187,7 @@ property list which is set as the value of a default.\n\n");
}
if (defs == nil) {
NSLog(@"defaults: unable to access defaults database!\n");
[pool release];
exit(0);
}
/* We don't want this tool in the defaults database - so remove it. */
@ -187,6 +195,7 @@ property list which is set as the value of a default.\n\n");
if ([args count] <= i) {
NSLog(@"defaults: too few arguments supplied!\n");
[pool release];
exit(0);
}
@ -207,6 +216,7 @@ property list which is set as the value of a default.\n\n");
else {
if ([args count] == ++i) {
NSLog(@"defaults: too few arguments supplied!\n");
[pool release];
exit(0);
}
owner = nil;
@ -305,12 +315,14 @@ property list which is set as the value of a default.\n\n");
}
if (*start == '\0') {
printf("defaults write: invalid input - nul domain name\n");
[pool release];
exit(0);
}
for (str = start; *str; str++) {
if (isspace(*str)) {
printf("defaults write: invalid input - "
"space in domain name.\n");
[pool release];
exit(0);
}
}
@ -333,12 +345,14 @@ property list which is set as the value of a default.\n\n");
if (*start == '\0') {
printf("defaults write: invalid input - "
"nul default name.\n");
[pool release];
exit(0);
}
for (str = start; *str; str++) {
if (isspace(*str)) {
printf("defaults write: invalid input - "
"space in default name.\n");
[pool release];
exit(0);
}
}
@ -368,12 +382,14 @@ property list which is set as the value of a default.\n\n");
else {
printf("defaults write: fatal error - "
"out of memory.\n");
[pool release];
exit(0);
}
}
if (fgets(ptr, BUFSIZ, stdin) == 0) {
printf("defaults write: invalid input - "
"no final quote.\n");
[pool release];
exit(0);
}
}
@ -399,6 +415,7 @@ property list which is set as the value of a default.\n\n");
if (*start == '\0') {
printf("defaults write: invalid input - "
"empty property list\n");
[pool release];
exit(0);
}
@ -413,6 +430,7 @@ property list which is set as the value of a default.\n\n");
if (tmp == nil) {
printf("defaults write: invalid input - "
"bad property list\n");
[pool release];
exit(0);
}
else {
@ -432,6 +450,7 @@ property list which is set as the value of a default.\n\n");
owner = [args objectAtIndex: i++];
if ([args count] <= i) {
NSLog(@"defaults: no dictionary or key for write!\n");
[pool release];
exit(0);
}
name = [args objectAtIndex: i++];
@ -447,6 +466,7 @@ property list which is set as the value of a default.\n\n");
if (obj == nil) {
printf("defaults write: invalid input - "
"bad property list\n");
[pool release];
exit(0);
}
}
@ -466,6 +486,7 @@ property list which is set as the value of a default.\n\n");
if (domain == nil ||
[domain isKindOfClass: [NSDictionary class]] == NO) {
NSLog(@"defaults write: domain is not a dictionary!\n");
[pool release];
exit(0);
}
}
@ -497,6 +518,7 @@ property list which is set as the value of a default.\n\n");
}
if (*start == '\0') {
printf("defaults delete: invalid input\n");
[pool release];
exit(0);
}
owner = [NSString stringWithCString: start];
@ -513,6 +535,7 @@ property list which is set as the value of a default.\n\n");
}
if (*start == '\0') {
printf("defaults delete: invalid input\n");
[pool release];
exit(0);
}
name = [NSString stringWithCString: start];
@ -566,6 +589,7 @@ property list which is set as the value of a default.\n\n");
else if ([[args objectAtIndex: i] isEqual: @"find"]) {
if ([args count] == ++i) {
NSLog(@"defaults: no arguments for find!\n");
[pool release];
exit(0);
}
name = [args objectAtIndex: i];
@ -612,9 +636,9 @@ property list which is set as the value of a default.\n\n");
}
else {
NSLog(@"defaults: unknown option supplied!\n");
exit(0);
}
[pool release];
exit(0);
}

View file

@ -26,11 +26,13 @@
#include <Foundation/NSString.h>
#include <Foundation/NSProcessInfo.h>
#include <Foundation/NSUserDefaults.h>
#include <Foundation/NSAutoreleasePool.h>
int
main(int argc, char** argv)
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSUserDefaults *defs;
NSProcessInfo *proc;
NSArray *args;
@ -44,6 +46,7 @@ main(int argc, char** argv)
proc = [NSProcessInfo processInfo];
if (proc == nil) {
NSLog(@"unable to get process information!\n");
[pool release];
exit(0);
}
@ -78,6 +81,7 @@ main(int argc, char** argv)
printf(
"dread [-u uname] key\n"
" read default named 'key' from the global domain.\n");
[pool release];
exit(0);
}
}
@ -85,6 +89,7 @@ main(int argc, char** argv)
i = 0;
if ([args count] <= i) {
NSLog(@"too few arguments supplied!\n");
[pool release];
exit(0);
}
@ -94,12 +99,14 @@ main(int argc, char** argv)
}
else {
NSLog(@"no name supplied for -u option!\n");
[pool release];
exit(0);
}
}
if ([args count] <= i) {
NSLog(@"too few arguments supplied!\n");
[pool release];
exit(0);
}
@ -110,6 +117,7 @@ main(int argc, char** argv)
}
else {
NSLog(@"no key supplied for -g option!\n");
[pool release];
exit(0);
}
}
@ -120,6 +128,7 @@ main(int argc, char** argv)
}
else {
NSLog(@"no key supplied for -n option!\n");
[pool release];
exit(0);
}
}
@ -130,6 +139,7 @@ main(int argc, char** argv)
}
else {
NSLog(@"no domain name supplied for -o option!\n");
[pool release];
exit(0);
}
}
@ -156,6 +166,7 @@ main(int argc, char** argv)
}
if (defs == nil) {
NSLog(@"unable to access defaults database!\n");
[pool release];
exit(0);
}
/* We don't want dwrite in the defaults database - so remove it. */
@ -218,6 +229,7 @@ main(int argc, char** argv)
printf("dread: couldn't read default\n");
}
[pool release];
exit(0);
}

View file

@ -26,12 +26,14 @@
#include <Foundation/NSString.h>
#include <Foundation/NSProcessInfo.h>
#include <Foundation/NSUserDefaults.h>
#include <errno.h>
#include <Foundation/NSDebug.h>
#include <Foundation/NSAutoreleasePool.h>
int
main(int argc, char** argv)
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSUserDefaults *defs;
NSProcessInfo *proc;
NSArray *args;
@ -44,6 +46,7 @@ main(int argc, char** argv)
proc = [NSProcessInfo processInfo];
if (proc == nil) {
NSLog(@"unable to get process information!\n");
[pool release];
exit(0);
}
@ -71,6 +74,7 @@ main(int argc, char** argv)
" read the standard input for a series of lines listing domain name and\n"
" default key pairs to be removed. Domain names and default keys must be\n"
" separated by spaces.\n");
[pool release];
exit(0);
}
}
@ -82,6 +86,7 @@ main(int argc, char** argv)
}
else {
NSLog(@"no name supplied for -u option!\n");
[pool release];
exit(0);
}
}
@ -94,6 +99,7 @@ main(int argc, char** argv)
}
if (defs == nil) {
NSLog(@"unable to access defaults database!\n");
[pool release];
exit(0);
}
@ -118,6 +124,7 @@ main(int argc, char** argv)
}
if (*start == '\0') {
printf("dremove: invalid input\n");
[pool release];
exit(0);
}
owner = [NSString stringWithCString: start];
@ -135,6 +142,7 @@ main(int argc, char** argv)
}
if (*start == '\0') {
printf("dremove: invalid input\n");
[pool release];
exit(0);
}
name = [NSString stringWithCString: start];
@ -156,6 +164,7 @@ main(int argc, char** argv)
}
else {
NSLog(@"no key supplied for -g option.\n");
[pool release];
exit(0);
}
domain = [[defs persistentDomainForName: owner] mutableCopy];
@ -174,6 +183,7 @@ main(int argc, char** argv)
}
else {
NSLog(@"no domain supplied for -o option.\n");
[pool release];
exit(0);
}
[defs removePersistentDomainForName: owner];
@ -195,6 +205,7 @@ main(int argc, char** argv)
else {
NSLog(@"got app name '%s' but no variable name.\n",
[[args objectAtIndex: 0] cString]);
[pool release];
exit(0);
}
}
@ -205,6 +216,7 @@ main(int argc, char** argv)
NSLog(@"unable to write to defaults database - %s\n", strerror(errno));
}
[pool release];
exit(0);
}

View file

@ -26,11 +26,13 @@
#include <Foundation/NSString.h>
#include <Foundation/NSProcessInfo.h>
#include <Foundation/NSUserDefaults.h>
#include <Foundation/NSAutoreleasePool.h>
int
main(int argc, char** argv)
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSUserDefaults *defs;
NSProcessInfo *proc;
NSArray *args;
@ -47,6 +49,7 @@ main(int argc, char** argv)
proc = [NSProcessInfo processInfo];
if (proc == nil) {
NSLog(@"unable to get process information!\n");
[pool release];
exit(0);
}
@ -75,6 +78,7 @@ main(int argc, char** argv)
" read the standard input for a series of lines listing defaults to be\n"
" written. Domain names, default keys, and default values must be\n"
" separated on each line by spaces.\n");
[pool release];
exit(0);
}
}
@ -86,6 +90,7 @@ main(int argc, char** argv)
}
else {
NSLog(@"no name supplied for -u option!\n");
[pool release];
exit(0);
}
}
@ -98,6 +103,7 @@ main(int argc, char** argv)
}
if (defs == nil) {
NSLog(@"unable to access defaults database!\n");
[pool release];
exit(0);
}
/* We don't want dwrite in the defaults database - so remove it. */
@ -125,11 +131,13 @@ main(int argc, char** argv)
}
if (*start == '\0') {
printf("dwrite: invalid input - nul domain name\n");
[pool release];
exit(0);
}
for (str = start; *str; str++) {
if (isspace(*str)) {
printf("dwrite: invalid input - space in domain name.\n");
[pool release];
exit(0);
}
}
@ -148,11 +156,13 @@ main(int argc, char** argv)
}
if (*start == '\0') {
printf("dwrite: invalid input - nul default name.\n");
[pool release];
exit(0);
}
for (str = start; *str; str++) {
if (isspace(*str)) {
printf("dwrite: invalid input - space in default name.\n");
[pool release];
exit(0);
}
}
@ -164,6 +174,7 @@ main(int argc, char** argv)
if (*ptr == '\0') {
if (fgets(ptr, sizeof(buf) - (ptr-buf), stdin) == 0) {
printf("dwrite: invalid input - no final quote.\n");
[pool release];
exit(0);
}
}
@ -189,6 +200,7 @@ main(int argc, char** argv)
}
if (*start == '\0') {
printf("dwrite: invalid input - empty property list\n");
[pool release];
exit(0);
}
obj = [NSString stringWithCString: start];
@ -197,6 +209,7 @@ main(int argc, char** argv)
if (tmp == nil) {
printf("dwrite: invalid input - bad property list\n");
[pool release];
exit(0);
}
else {
@ -219,6 +232,7 @@ main(int argc, char** argv)
for (str = [name cString]; *str; str++) {
if (isspace(*str)) {
printf("dwrite: invalid input - space in default name.\n");
[pool release];
exit(0);
}
}
@ -232,6 +246,7 @@ main(int argc, char** argv)
}
if (obj == nil) {
printf("dwrite: invalid input - bad property list\n");
[pool release];
exit(0);
}
domain = [[defs persistentDomainForName: owner] mutableCopy];
@ -243,6 +258,7 @@ main(int argc, char** argv)
}
else {
NSLog(@"too few arguments supplied!\n");
[pool release];
exit(0);
}
}
@ -252,6 +268,7 @@ main(int argc, char** argv)
for (str = [owner cString]; *str; str++) {
if (isspace(*str)) {
printf("dwrite: invalid input - space in domain name.\n");
[pool release];
exit(0);
}
}
@ -259,6 +276,7 @@ main(int argc, char** argv)
for (str = [name cString]; *str; str++) {
if (isspace(*str)) {
printf("dwrite: invalid input - space in default name.\n");
[pool release];
exit(0);
}
}
@ -272,6 +290,7 @@ main(int argc, char** argv)
}
if (obj == nil) {
printf("dwrite: invalid input - bad property list\n");
[pool release];
exit(0);
}
domain = [[defs persistentDomainForName: owner] mutableCopy];
@ -283,12 +302,14 @@ main(int argc, char** argv)
}
else {
NSLog(@"too few arguments supplied!\n");
[pool release];
exit(0);
}
}
[defs synchronize];
[pool release];
exit(0);
}