]> git.saurik.com Git - apple/xnu.git/blobdiff - iokit/Kernel/IOSimpleReporter.cpp
xnu-7195.101.1.tar.gz
[apple/xnu.git] / iokit / Kernel / IOSimpleReporter.cpp
index 7807763a9f09ffd6c0d08b082462f9c293db9850..fc29f24c3d27652c43d911ed8e1a3feff9ef5691 100644 (file)
@@ -26,6 +26,9 @@
  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
 
+#define IOKIT_ENABLE_SHARED_PTR
+
+#include <libkern/c++/OSSharedPtr.h>
 #include <IOKit/IOKernelReportStructs.h>
 #include <IOKit/IOKernelReporters.h>
 #include "IOReporterDefs.h"
 OSDefineMetaClassAndStructors(IOSimpleReporter, IOReporter);
 
 /* static */
-IOSimpleReporter*
+OSSharedPtr<IOSimpleReporter>
 IOSimpleReporter::with(IOService *reportingService,
     IOReportCategories categories,
     IOReportUnit unit)
 {
-       IOSimpleReporter *reporter, *rval = NULL;
-
-       // kprintf("%s\n", __func__);      // can't IORLOG() from static
+       OSSharedPtr<IOSimpleReporter> reporter;
 
-       reporter = new IOSimpleReporter;
+       reporter = OSMakeShared<IOSimpleReporter>();
        if (!reporter) {
-               goto finish;
+               return nullptr;
        }
 
-
        if (!reporter->initWith(reportingService, categories, unit)) {
-               goto finish;
-       }
-
-       // success
-       rval = reporter;
-
-finish:
-       if (!rval) {
-               OSSafeReleaseNULL(reporter);
+               return nullptr;
        }
 
-       return rval;
+       return reporter;
 }
 
 bool