Differences From Artifact [a1bb959d69]:
- File src/OFProcess.m — part of check-in [8892ae9fcc] at 2012-07-12 01:28:46 on branch trunk — Don't access isa directly. (user: js, size: 7817) [annotate] [blame] [check-ins using]
To Artifact [769871dec1]:
- File
src/OFProcess.m
— part of check-in
[1255f3a11a]
at
2012-08-10 20:08:24
on branch trunk
— Directly use the runtime's autorelease pools.
This greatly improves performance, as it gets rid of the overhead of
OFAutoreleasePool. (user: js, size: 7808) [annotate] [blame] [check-ins using]
| ︙ | ︙ | |||
22 23 24 25 26 27 28 | # include <unistd.h> # include <sys/wait.h> #endif #import "OFProcess.h" #import "OFString.h" #import "OFArray.h" | < > > | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# include <unistd.h>
# include <sys/wait.h>
#endif
#import "OFProcess.h"
#import "OFString.h"
#import "OFArray.h"
#import "OFInitializationFailedException.h"
#import "OFReadFailedException.h"
#import "OFWriteFailedException.h"
#ifdef _WIN32
# include <windows.h>
#endif
#import "autorelease.h"
@implementation OFProcess
+ processWithProgram: (OFString*)program
{
return [[[self alloc] initWithProgram: program] autorelease];
}
|
| ︙ | ︙ | |||
121 122 123 124 125 126 127 | close(writePipe[0]); break; } #else SECURITY_ATTRIBUTES sa; PROCESS_INFORMATION pi; STARTUPINFO si; | | | 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | close(writePipe[0]); break; } #else SECURITY_ATTRIBUTES sa; PROCESS_INFORMATION pi; STARTUPINFO si; void *pool; OFMutableString *argumentsString; OFEnumerator *enumerator; OFString *argument; char *argumentsCString; sa.nLength = sizeof(sa); sa.bInheritHandle = TRUE; |
| ︙ | ︙ | |||
156 157 158 159 160 161 162 | si.cb = sizeof(si); si.hStdInput = writePipe[0]; si.hStdOutput = readPipe[1]; si.hStdError = GetStdHandle(STD_ERROR_HANDLE); si.dwFlags |= STARTF_USESTDHANDLES; | | | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | si.cb = sizeof(si); si.hStdInput = writePipe[0]; si.hStdOutput = readPipe[1]; si.hStdError = GetStdHandle(STD_ERROR_HANDLE); si.dwFlags |= STARTF_USESTDHANDLES; pool = objc_autoreleasePoolPush(); argumentsString = [OFMutableString stringWithString: programName]; [argumentsString replaceOccurrencesOfString: @"\\\"" withString: @"\\\\\""]; [argumentsString replaceOccurrencesOfString: @"\"" withString: @"\\\""]; |
| ︙ | ︙ | |||
204 205 206 207 208 209 210 |
NULL, TRUE, 0, NULL, NULL, &si, &pi))
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
} @finally {
free(argumentsString);
}
| | | 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
NULL, TRUE, 0, NULL, NULL, &si, &pi))
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
} @finally {
free(argumentsString);
}
objc_autoreleasePoolPop(pool);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
CloseHandle(readPipe[1]);
CloseHandle(writePipe[0]);
#endif
|
| ︙ | ︙ |