Skip to content

Commit

Permalink
Made project build for all architectures (include arm64)
Browse files Browse the repository at this point in the history
Fixed some memory leaks that the clang analyzer pointed out
  • Loading branch information
cjhanson committed Dec 18, 2013
1 parent d4d0c6a commit 673626b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions SVGKit-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer: Lei Lei (JV5Y7A3TGE)";
Expand All @@ -1217,7 +1217,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer: Lei Lei (JV5Y7A3TGE)";
Expand Down
4 changes: 2 additions & 2 deletions Source/DOM classes/Core DOM/NamedNodeMap.m
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ -(NSDictionary*) allNodesUnsortedDOM2
-(id)copyWithZone:(NSZone *)zone
{
NamedNodeMap* clone = [[NamedNodeMap allocWithZone:zone] init];
clone.internalDictionary = [self.internalDictionary copyWithZone:zone];
clone.internalDictionaryOfNamespaces = [self.internalDictionaryOfNamespaces copyWithZone:zone];
clone.internalDictionary = [[self.internalDictionary copyWithZone:zone] autorelease];
clone.internalDictionaryOfNamespaces = [[self.internalDictionaryOfNamespaces copyWithZone:zone] autorelease];

return clone;
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Parsers/SVGKParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ - (NSString *)stringFromSource:(SVGKSource *) src
do
{
bytesRead = [src.stream read:byteBuffer maxLength:4096];
NSString *read = [[NSString alloc] initWithBytes:byteBuffer length:bytesRead encoding:NSUTF8StringEncoding];
NSString *read = [[[NSString alloc] initWithBytes:byteBuffer length:bytesRead encoding:NSUTF8StringEncoding] autorelease];
if( result )
result = [result stringByAppendingString:read];
else
Expand Down Expand Up @@ -326,7 +326,7 @@ - (void)handleProcessingInstruction:(NSString *)target withData:(NSString *) dat
if( currentParseRun.parsedDocument.rootElement == nil )
{
if( self.externalStylesheets == nil )
self.externalStylesheets = [[NSMutableArray alloc] init];
self.externalStylesheets = [[[NSMutableArray alloc] init] autorelease];
[self.externalStylesheets addObject:parsedStylesheet];
}
else
Expand Down
10 changes: 5 additions & 5 deletions Source/QuartzCore additions/CALayer+RecursiveClone.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ -(CALayer*) cloneOptionallRecurse:(BOOL) shouldRecurse
specificClone.borderColor = selfSpecific.borderColor;
specificClone.opacity = selfSpecific.opacity;
specificClone.compositingFilter = selfSpecific.compositingFilter;
specificClone.filters = [selfSpecific.filters copy];
specificClone.backgroundFilters = [selfSpecific.backgroundFilters copy];
specificClone.filters = [[selfSpecific.filters copy] autorelease];
specificClone.backgroundFilters = [[selfSpecific.backgroundFilters copy] autorelease];
specificClone.shouldRasterize = selfSpecific.shouldRasterize;
specificClone.rasterizationScale = selfSpecific.rasterizationScale;
specificClone.shadowColor = selfSpecific.shadowColor;
Expand All @@ -69,7 +69,7 @@ -(CALayer*) cloneOptionallRecurse:(BOOL) shouldRecurse
specificClone.shadowRadius = selfSpecific.shadowRadius;
specificClone.shadowPath = selfSpecific.shadowPath;
specificClone.name = selfSpecific.name;
specificClone.style = [selfSpecific.style copy];
specificClone.style = [[selfSpecific.style copy] autorelease];
}

if( [clone isKindOfClass:[CAGradientLayer class]])
Expand All @@ -80,8 +80,8 @@ -(CALayer*) cloneOptionallRecurse:(BOOL) shouldRecurse
specificClone.startPoint = selfSpecific.startPoint;
specificClone.endPoint = selfSpecific.endPoint;
specificClone.type = selfSpecific.type;
specificClone.colors = [selfSpecific.colors copy];
specificClone.locations = [selfSpecific.locations copy];
specificClone.colors = [[selfSpecific.colors copy] autorelease];
specificClone.locations = [[selfSpecific.locations copy] autorelease];
}

if( [clone isKindOfClass:[CAShapeLayer class]])
Expand Down
42 changes: 21 additions & 21 deletions Source/QuartzCore additions/SVGGradientLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,29 @@ - (void)renderInContext:(CGContextRef)ctx {
CGColorRef colorRef = (CGColorRef)[self.colors objectAtIndex:0];
numbOfComponents = CGColorGetNumberOfComponents(colorRef);
colorSpace = CGColorGetColorSpace(colorRef);
}

float *locations = calloc(num_locations, sizeof(float));
float *components = calloc(num_locations, numbOfComponents * sizeof(float));

for (int x = 0; x < num_locations; x++) {
locations[x] = [[self.locations objectAtIndex:x] floatValue];
const CGFloat *comps = CGColorGetComponents((CGColorRef)[self.colors objectAtIndex:x]);
for (int y = 0; y < numbOfComponents; y++) {
int shift = numbOfComponents * x;
components[shift + y] = comps[y];
float *locations = calloc(num_locations, sizeof(float));
float *components = calloc(num_locations, numbOfComponents * sizeof(float));
for (int x = 0; x < num_locations; x++) {
locations[x] = [[self.locations objectAtIndex:x] floatValue];
const CGFloat *comps = CGColorGetComponents((CGColorRef)[self.colors objectAtIndex:x]);
for (int y = 0; y < numbOfComponents; y++) {
int shift = numbOfComponents * x;
components[shift + y] = comps[y];
}
}

CGPoint position = self.startPoint;
CGFloat radius = floorf(self.endPoint.x * self.bounds.size.width);
CGGradientRef gradient = CGGradientCreateWithColorComponents(colorSpace, components, locations, num_locations);

CGContextDrawRadialGradient(ctx, gradient, position, 0, position, radius, kCGGradientDrawsAfterEndLocation);

free(locations);
free(components);
CGGradientRelease(gradient);
}

CGPoint position = self.startPoint;
CGFloat radius = floorf(self.endPoint.x * self.bounds.size.width);
CGGradientRef gradient = CGGradientCreateWithColorComponents(colorSpace, components, locations, num_locations);

CGContextDrawRadialGradient(ctx, gradient, position, 0, position, radius, kCGGradientDrawsAfterEndLocation);

free(locations);
free(components);
CGGradientRelease(gradient);
} else {
[super renderInContext:ctx];
}
Expand Down

0 comments on commit 673626b

Please sign in to comment.