blob: 32a88db1e97a01a9d587742c40a26b51acd67df4 [file] [log] [blame]
// Copyright 2013 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Chromium's foundation_util.cc pulls a lot of mac related functions into the
// base package. We don't need them, so strip down all the code.
#include "base/mac/foundation_util.h"
namespace base {
namespace mac {
void* CFTypeRefToNSObjectAutorelease(CFTypeRef cf_object) {
// When GC is on, NSMakeCollectable marks cf_object for GC and autorelease
// is a no-op.
//
// In the traditional GC-less environment, NSMakeCollectable is a no-op,
// and cf_object is autoreleased, balancing out the caller's ownership claim.
//
// NSMakeCollectable returns nil when used on a NULL object.
return [NSMakeCollectable(cf_object) autorelease];
}
} // namespace mac
} // namespace base