Skip to content
This repository has been archived by the owner on Jan 4, 2022. It is now read-only.

Commit

Permalink
ARC compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
billgarrison committed Jan 19, 2012
1 parent bab2f94 commit 3beaf58
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions SOLogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
#import "SOLogger.h"
#import <asl.h>

#ifndef __has_feature
#define __has_feature(x) 0
#endif

#define NO_ARC !__has_feature(objc_arc)

#if SOLOGGER_DEBUG
static inline void LOG_ASLCLIENT(const char *where, aslclient ASLClient);
#endif
Expand Down Expand Up @@ -39,7 +45,9 @@ - (id) initWithLogger:(SOLogger *)logger facility:(NSString *)facility options:(

if (logger == nil)
{
#if NO_ARC
[self release];
#endif
return nil;
}
//const char *normalizedFacility = (facility) ? [facility UTF8String] : "com.apple.console";
Expand Down Expand Up @@ -81,7 +89,9 @@ - (void) dealloc
if (death_rattle) free(death_rattle);
#endif

#if NO_ARC
[super dealloc];
#endif
}

- (aslclient) aslclientRef
Expand Down Expand Up @@ -193,21 +203,24 @@ - (void) dealloc;
/* Broadcast to dependent ASL clients that we're going away */
[[NSNotificationCenter defaultCenter] postNotificationName:SOLoggerWillDieNotification object:self];

#if NO_ARC
[_ASLClientCache release];
_ASLClientCache = nil;
[_facility release];
[_extraLoggingDescriptors release];
#endif

[_facility release];
_ASLClientCache = nil;
_facility = nil;

[_extraLoggingDescriptors release];
_extraLoggingDescriptors = nil;

#if SOLOGGER_DEBUG
NSThread *currentThread = [NSThread currentThread];
NSLog(@"Deallocating %@ on %@ thread %p", self, ([currentThread isMainThread] ? @"main" : @"background"), currentThread);
#endif

#if NO_ARC
[super dealloc];
#endif
}

/*
Expand All @@ -234,8 +247,9 @@ - (aslclient) aslclientRef
/* Cache the new ASL client
*/
[_ASLClientCache setObject:ASLClient forKey:threadKey];
#if NO_ARC
[ASLClient release];

#endif
/* Configure the connection's filter mask.
*/
asl_set_filter ([ASLClient aslclientRef], [self severityFilterMask]);
Expand Down Expand Up @@ -354,7 +368,9 @@ - (void) logWithLevel:(int)aslLevel format:(NSString *)format arguments:(va_list
{
NSLog (@"asl_log() failed to write the message: %@", text);
}
#if NO_ARC
[text release];
#endif
text = nil;

// Cleanup
Expand Down

0 comments on commit 3beaf58

Please sign in to comment.