Skip to content

Commit 8256048

Browse files
committed
Merge branch 'arc'
2 parents 1a8ae62 + 3ecb7c3 commit 8256048

File tree

6 files changed

+159
-259
lines changed

6 files changed

+159
-259
lines changed

KissXML/Categories/NSString+DDXML.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#import "NSString+DDXML.h"
22

3+
#if ! __has_feature(objc_arc)
4+
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
5+
#endif
36

47
@implementation NSString (DDXML)
58

@@ -17,12 +20,11 @@ - (NSString *)stringByTrimming
1720
- (NSString *)stringByTrimming
1821
{
1922
NSMutableString *mStr = [self mutableCopy];
20-
CFStringTrimWhitespace((CFMutableStringRef)mStr);
23+
CFStringTrimWhitespace((__bridge CFMutableStringRef)mStr);
2124

2225
NSString *result = [mStr copy];
2326

24-
[mStr release];
25-
return [result autorelease];
27+
return result;
2628
}
2729
#endif
2830

KissXML/DDXMLDocument.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#import "DDXMLPrivate.h"
22
#import "NSString+DDXML.h"
33

4+
#if ! __has_feature(objc_arc)
5+
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
6+
#endif
7+
48
/**
59
* Welcome to KissXML.
610
*
@@ -27,7 +31,7 @@ @implementation DDXMLDocument
2731
**/
2832
+ (id)nodeWithDocPrimitive:(xmlDocPtr)doc owner:(DDXMLNode *)owner
2933
{
30-
return [[[DDXMLDocument alloc] initWithDocPrimitive:doc owner:owner] autorelease];
34+
return [[DDXMLDocument alloc] initWithDocPrimitive:doc owner:owner];
3135
}
3236

3337
- (id)initWithDocPrimitive:(xmlDocPtr)doc owner:(DDXMLNode *)inOwner
@@ -49,7 +53,6 @@ - (id)initWithPrimitive:(xmlKindPtr)kindPtr owner:(DDXMLNode *)inOwner
4953
// Promote initializers which use proper parameter types to enable compiler to catch more mistakes.
5054
NSAssert(NO, @"Use initWithDocPrimitive:owner:");
5155

52-
[self release];
5356
return nil;
5457
}
5558

@@ -78,7 +81,6 @@ - (id)initWithData:(NSData *)data options:(NSUInteger)mask error:(NSError **)err
7881
{
7982
if (error) *error = [NSError errorWithDomain:@"DDXMLErrorDomain" code:0 userInfo:nil];
8083

81-
[self release];
8284
return nil;
8385
}
8486

@@ -94,7 +96,6 @@ - (id)initWithData:(NSData *)data options:(NSUInteger)mask error:(NSError **)err
9496
{
9597
if (error) *error = [NSError errorWithDomain:@"DDXMLErrorDomain" code:1 userInfo:nil];
9698

97-
[self release];
9899
return nil;
99100
}
100101

KissXML/DDXMLElement.m

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#import "DDXMLPrivate.h"
22
#import "NSString+DDXML.h"
33

4+
#if ! __has_feature(objc_arc)
5+
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
6+
#endif
7+
48
/**
59
* Welcome to KissXML.
610
*
@@ -27,7 +31,7 @@ @implementation DDXMLElement
2731
**/
2832
+ (id)nodeWithElementPrimitive:(xmlNodePtr)node owner:(DDXMLNode *)owner
2933
{
30-
return [[[DDXMLElement alloc] initWithElementPrimitive:node owner:owner] autorelease];
34+
return [[DDXMLElement alloc] initWithElementPrimitive:node owner:owner];
3135
}
3236

3337
- (id)initWithElementPrimitive:(xmlNodePtr)node owner:(DDXMLNode *)inOwner
@@ -49,7 +53,6 @@ - (id)initWithPrimitive:(xmlKindPtr)kindPtr owner:(DDXMLNode *)inOwner
4953
// Promote initializers which use proper parameter types to enable compiler to catch more mistakes.
5054
NSAssert(NO, @"Use initWithElementPrimitive:owner:");
5155

52-
[self release];
5356
return nil;
5457
}
5558

@@ -60,7 +63,6 @@ - (id)initWithName:(NSString *)name
6063
xmlNodePtr node = xmlNewNode(NULL, [name xmlChar]);
6164
if (node == NULL)
6265
{
63-
[self release];
6466
return nil;
6567
}
6668

@@ -74,7 +76,6 @@ - (id)initWithName:(NSString *)name URI:(NSString *)URI
7476
xmlNodePtr node = xmlNewNode(NULL, [name xmlChar]);
7577
if (node == NULL)
7678
{
77-
[self release];
7879
return nil;
7980
}
8081

@@ -91,7 +92,6 @@ - (id)initWithName:(NSString *)name stringValue:(NSString *)string
9192
xmlNodePtr node = xmlNewNode(NULL, [name xmlChar]);
9293
if (node == NULL)
9394
{
94-
[self release];
9595
return nil;
9696
}
9797

@@ -106,16 +106,13 @@ - (id)initWithXMLString:(NSString *)string error:(NSError **)error
106106
DDXMLDocument *doc = [[DDXMLDocument alloc] initWithXMLString:string options:0 error:error];
107107
if (doc == nil)
108108
{
109-
[self release];
110109
return nil;
111110
}
112111

113112
DDXMLElement *result = [doc rootElement];
114113
[result detach];
115-
[doc release];
116114

117-
[self release];
118-
return [result retain];
115+
return result;
119116
}
120117

121118
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -326,8 +323,7 @@ - (void)addAttribute:(DDXMLNode *)attribute
326323
xmlAddChild((xmlNodePtr)genericPtr, (xmlNodePtr)attribute->genericPtr);
327324

328325
// The attribute is now part of the xml tree heirarchy
329-
[attribute->owner release];
330-
attribute->owner = [self retain];
326+
attribute->owner = self;
331327
}
332328

333329
- (void)removeAttributeForName:(NSString *)name
@@ -476,8 +472,7 @@ - (void)_addNamespace:(DDXMLNode *)namespace
476472
}
477473

478474
// The namespace is now part of the xml tree heirarchy
479-
[namespace->owner release];
480-
namespace->owner = [self retain];
475+
namespace->owner = self;
481476

482477
if ([namespace isKindOfClass:[DDXMLNamespaceNode class]])
483478
{
@@ -710,8 +705,7 @@ - (void)addChild:(DDXMLNode *)child
710705
xmlAddChild((xmlNodePtr)genericPtr, (xmlNodePtr)child->genericPtr);
711706

712707
// The node is now part of the xml tree heirarchy
713-
[child->owner release];
714-
child->owner = [self retain];
708+
child->owner = self;
715709
}
716710

717711
- (void)insertChild:(DDXMLNode *)child atIndex:(NSUInteger)index
@@ -737,8 +731,7 @@ - (void)insertChild:(DDXMLNode *)child atIndex:(NSUInteger)index
737731
{
738732
xmlAddPrevSibling(childNodePtr, (xmlNodePtr)child->genericPtr);
739733

740-
[child->owner release];
741-
child->owner = [self retain];
734+
child->owner = self;
742735

743736
return;
744737
}
@@ -752,8 +745,7 @@ - (void)insertChild:(DDXMLNode *)child atIndex:(NSUInteger)index
752745
{
753746
xmlAddChild((xmlNodePtr)genericPtr, (xmlNodePtr)child->genericPtr);
754747

755-
[child->owner release];
756-
child->owner = [self retain];
748+
child->owner = self;
757749

758750
return;
759751
}

0 commit comments

Comments
 (0)