* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
+#define IOKIT_ENABLE_SHARED_PTR
+
#define __STDC_LIMIT_MACROS // what are the C++ equivalents?
#include <stdint.h>
OSDefineMetaClassAndStructors(IOHistogramReporter, IOReporter);
/* static */
-IOHistogramReporter*
+OSSharedPtr<IOHistogramReporter>
IOHistogramReporter::with(IOService *reportingService,
IOReportCategories categories,
uint64_t channelID,
int nSegments,
IOHistogramSegmentConfig *config)
{
- IOHistogramReporter *reporter = new IOHistogramReporter;
-
- const OSSymbol *tmpChannelName = NULL;
+ OSSharedPtr<IOHistogramReporter> reporter = OSMakeShared<IOHistogramReporter>();
+ OSSharedPtr<const OSSymbol> tmpChannelName;
if (reporter) {
if (channelName) {
}
if (reporter->initWith(reportingService, categories,
- channelID, tmpChannelName,
+ channelID, tmpChannelName.get(),
unit, nSegments, config)) {
return reporter;
}
}
- OSSafeReleaseNULL(reporter);
- OSSafeReleaseNULL(tmpChannelName);
- return 0;
+ return nullptr;
}
// Setup IOReporter's channel type
_elements[cnt2].channel_type = _channelType;
- _elements[cnt2].channel_type.element_idx = cnt2;
+ _elements[cnt2].channel_type.element_idx = ((int16_t) cnt2);
//IOREPORTER_DEBUG_ELEMENT(cnt2);
}
}
-IOReportLegendEntry*
+OSSharedPtr<IOReportLegendEntry>
IOHistogramReporter::handleCreateLegend(void)
{
- IOReportLegendEntry *rval = NULL, *legendEntry = NULL;
- OSData *tmpConfigData = NULL;
- OSDictionary *tmpDict; // no refcount
+ OSSharedPtr<IOReportLegendEntry> legendEntry;
+ OSSharedPtr<OSData> tmpConfigData;
+ OSDictionary *tmpDict; // no refcount
legendEntry = super::handleCreateLegend();
if (!legendEntry) {
- goto finish;
+ return nullptr;
}
PREFL_MEMOP_PANIC(_segmentCount, IOHistogramSegmentConfig);
(unsigned)_segmentCount *
sizeof(IOHistogramSegmentConfig));
if (!tmpConfigData) {
- goto finish;
+ return nullptr;
}
tmpDict = OSDynamicCast(OSDictionary,
legendEntry->getObject(kIOReportLegendInfoKey));
if (!tmpDict) {
- goto finish;
+ return nullptr;
}
- tmpDict->setObject(kIOReportLegendConfigKey, tmpConfigData);
-
- // success
- rval = legendEntry;
-
-finish:
- if (tmpConfigData) {
- tmpConfigData->release();
- }
- if (!rval && legendEntry) {
- legendEntry->release();
- }
+ tmpDict->setObject(kIOReportLegendConfigKey, tmpConfigData.get());
- return rval;
+ return legendEntry;
}
IOReturn