Skip to content

Commit 7fe656b

Browse files
committed
Prefer ARC-scoped release rather than autorelease in the API
* Creating old entry stream and data is now by convention “ns_returns_retained”, which stops autoreleasing on returning large data (see @f5abe34).
1 parent 84f7a07 commit 7fe656b

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

zipzap/ZZArchiveEntry.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,14 @@
162162
*
163163
* @return The new stream: *nil* for new entries.
164164
*/
165-
- (NSInputStream*)stream;
165+
- (NSInputStream*)newStream;
166166

167167
/**
168168
* Creates data to represent the entry file.
169169
*
170170
* @return The new data: *nil* for new entries.
171171
*/
172-
- (NSData*)data;
172+
- (NSData*)newData;
173173

174174
/**
175175
* Creates a data provider to represent the entry file.

zipzap/ZZArchiveEntry.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ - (NSString*)fileName
115115
return nil;
116116
}
117117

118-
- (NSInputStream*)stream
118+
- (NSInputStream*)newStream
119119
{
120120
return nil;
121121
}
@@ -125,7 +125,7 @@ - (BOOL)check:(NSError **)error
125125
return YES;
126126
}
127127

128-
- (NSData*)data
128+
- (NSData*)newData
129129
{
130130
return nil;
131131
}

zipzap/ZZOldArchiveEntry.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333

3434
- (BOOL)check:(NSError **)error;
3535

36-
- (NSInputStream*)stream;
37-
- (NSData*)data;
36+
- (NSInputStream*)newStream;
37+
- (NSData*)newData;
3838
- (CGDataProviderRef)newDataProvider;
3939

4040
@end

zipzap/ZZOldArchiveEntry.mm

+2-2
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ - (BOOL)check:(NSError**)error
186186
return YES;
187187
}
188188

189-
- (NSInputStream*)stream
189+
- (NSInputStream*)newStream
190190
{
191191
switch (_centralFileHeader->compressionMethod)
192192
{
@@ -201,7 +201,7 @@ - (NSInputStream*)stream
201201
}
202202
}
203203

204-
- (NSData*)data
204+
- (NSData*)newData
205205
{
206206
switch (_centralFileHeader->compressionMethod)
207207
{

zipzapTests/ZZUnzipTests.m

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ - (void)checkExtractingZipEntryStreamWithChunkSize:(NSUInteger)chunkSize
6262
ZZArchiveEntry* nextEntry = _zipFile.entries[index];
6363
NSString* nextEntryFilePath = _entryFilePaths[index];
6464

65-
NSInputStream* stream = [nextEntry stream];
65+
NSInputStream* stream = [nextEntry newStream];
6666

6767
[stream open];
6868

@@ -210,7 +210,7 @@ - (void)testZipFromDataConsistentWithZipFromURL
210210

211211
XCTAssertEqual(zipEntry.crc32, zipFromDataEntry.crc32, @"zipFromDataEntry.entries[%lu].crc32 must match the reference entry.", (unsigned long)index);
212212

213-
XCTAssertEqualObjects(zipEntry.data, zipFromDataEntry.data, @"zipFromDataEntry.entries[%lu].data must match the reference entry.", (unsigned long)index);
213+
XCTAssertEqualObjects([zipEntry newData], [zipFromDataEntry newData], @"zipFromDataEntry.entries[%lu].data must match the reference entry.", (unsigned long)index);
214214

215215
XCTAssertEqual(zipEntry.fileMode, zipFromDataEntry.fileMode, @"zipFromDataEntry.entries[%lu].fileMode must match the reference entry.", (unsigned long)index);
216216

@@ -229,7 +229,7 @@ - (void)testExtractingZipEntryData
229229
ZZArchiveEntry* nextEntry = _zipFile.entries[index];
230230
NSString* nextEntryFilePath = _entryFilePaths[index];
231231

232-
XCTAssertEqualObjects(nextEntry.data,
232+
XCTAssertEqualObjects([nextEntry newData],
233233
[self dataAtFilePath:nextEntryFilePath],
234234
@"zipFile.entries[%lu].data must match the original file data.",
235235
(unsigned long)index);

0 commit comments

Comments
 (0)