Loading...
iokit/Kernel/IOInterruptEventSource.cpp xnu-7195.60.75 xnu-8792.81.2
--- xnu/xnu-7195.60.75/iokit/Kernel/IOInterruptEventSource.cpp
+++ xnu/xnu-8792.81.2/iokit/Kernel/IOInterruptEventSource.cpp
@@ -84,17 +84,15 @@
 {
 	bool res = true;
 
+	if (inIntIndex < 0) {
+		return false;
+	}
+
 	if (!super::init(inOwner, (IOEventSourceAction) inAction)) {
 		return false;
 	}
 
-	reserved = IONew(ExpansionData, 1);
-
-	if (!reserved) {
-		return false;
-	}
-
-	bzero(reserved, sizeof(ExpansionData));
+	reserved = IOMallocType(ExpansionData);
 
 	provider = inProvider;
 	producerCount = consumerCount = 0;
@@ -113,17 +111,7 @@
 			 * We also avoid try to avoid interrupt accounting overhead if none of
 			 * the statistics are enabled.
 			 */
-			reserved->statistics = IONew(IOInterruptAccountingData, 1);
-
-			if (!reserved->statistics) {
-				/*
-				 * We rely on the free() routine to clean up after us if init fails
-				 * midway.
-				 */
-				return false;
-			}
-
-			bzero(reserved->statistics, sizeof(IOInterruptAccountingData));
+			reserved->statistics = IOMallocType(IOInterruptAccountingData);
 
 			reserved->statistics->owner = this;
 		}
@@ -251,10 +239,10 @@
 
 	if (reserved) {
 		if (reserved->statistics) {
-			IODelete(reserved->statistics, IOInterruptAccountingData, 1);
-		}
-
-		IODelete(reserved, ExpansionData, 1);
+			IOFreeType(reserved->statistics, IOInterruptAccountingData);
+		}
+
+		IOFreeType(reserved, ExpansionData);
 	}
 
 	super::free();
@@ -425,8 +413,9 @@
 		}
 
 		if (reserved->statistics) {
-			if (IA_GET_STATISTIC_ENABLED(kInterruptAccountingSecondLevelCountIndex)) {
-				IA_ADD_VALUE(&reserved->statistics->interruptStatistics[kInterruptAccountingSecondLevelCountIndex], 1);
+			if (IA_GET_STATISTIC_ENABLED(kInterruptAccountingSecondLevelSystemTimeIndex)) {
+				endSystemTime = mach_absolute_time();
+				IA_ADD_VALUE(&reserved->statistics->interruptStatistics[kInterruptAccountingSecondLevelSystemTimeIndex], endSystemTime - startSystemTime);
 			}
 
 			if (IA_GET_STATISTIC_ENABLED(kInterruptAccountingSecondLevelCPUTimeIndex)) {
@@ -434,9 +423,8 @@
 				IA_ADD_VALUE(&reserved->statistics->interruptStatistics[kInterruptAccountingSecondLevelCPUTimeIndex], endCPUTime - startCPUTime);
 			}
 
-			if (IA_GET_STATISTIC_ENABLED(kInterruptAccountingSecondLevelSystemTimeIndex)) {
-				endSystemTime = mach_absolute_time();
-				IA_ADD_VALUE(&reserved->statistics->interruptStatistics[kInterruptAccountingSecondLevelSystemTimeIndex], endSystemTime - startSystemTime);
+			if (IA_GET_STATISTIC_ENABLED(kInterruptAccountingSecondLevelCountIndex)) {
+				IA_ADD_VALUE(&reserved->statistics->interruptStatistics[kInterruptAccountingSecondLevelCountIndex], 1);
 			}
 		}