#include "StreamSource.h"
#include <string>
#include "misc.h"
+#include "SecCFRelease.h"
using namespace std;
mReading(dispatch_group_create())
{
dispatch_group_enter(mReading);
- CFRetain(mReadStream);
+ CFRetainSafe(mReadStream);
}
void StreamSource::BackgroundActivate()
CFErrorRef error = mDestination->SetAttribute(mDestinationName, data);
- CFRelease(data);
+ CFReleaseNull(data);
if (error != NULL) // we have a problem, there was probably an abort on the chain
{
if (error)
{
// NOTE: CF doesn't always tell us about this error. Arguably it could be better to
- // "invent" a generic error, but it is a hard argument that we want to crash in CFRelease(NULL)...
- CFRelease(error);
+ // "invent" a generic error, but it is a hard argument that we want to crash in CFReleaseNull(NULL)...
+ CFReleaseNull(error);
}
}
else
void StreamSource::DoActivate()
{
- CFRetain(mDestination->GetCFObject());
+ CFRetainSafe(mDestination->GetCFObject());
dispatch_group_async(mReading, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
this->BackgroundActivate();
- CFRelease(mDestination->GetCFObject());
+ CFReleaseSafe(mDestination->GetCFObject());
});
dispatch_group_leave(mReading);
}
StreamSource::~StreamSource()
{
- CFRelease(mReadStream);
+ CFReleaseNull(mReadStream);
mReadStream = NULL;
dispatch_release(mReading);
mReading = NULL;