fix segfault with m5 cpu (#27)
The M5 Pro and Max do not have e cores, so the likely scenario is that
the eCoreRef is unitialized and resulting in a seg fault when trying to
get the frequency.
diff --git a/cpu.go b/cpu.go
index ceee2e1..2ff008a 100644
--- a/cpu.go
+++ b/cpu.go
@@ -30,6 +30,9 @@
// char global_brand[32];
//
// UInt64 getFrequency(CFTypeRef typeRef) {
+// if (typeRef == NULL) {
+// return 0;
+// }
// CFDataRef cfData = typeRef;
//
// CFIndex size = CFDataGetLength(cfData);
@@ -80,8 +83,9 @@
// IORegistryEntryGetName(obj, name);
//
// if (strncmp(name, "pmgr", BUFSIZE) == 0) {
-// CFTypeRef pCoreRef = IORegistryEntryCreateCFProperty(obj, CFSTR("voltage-states5-sram"), kCFAllocatorDefault, 0);
-// CFTypeRef eCoreRef = IORegistryEntryCreateCFProperty(obj, CFSTR("voltage-states1-sram"), kCFAllocatorDefault, 0);
+// CFTypeRef pCoreRef = NULL, eCoreRef = NULL;
+// pCoreRef = IORegistryEntryCreateCFProperty(obj, CFSTR("voltage-states5-sram"), kCFAllocatorDefault, 0);
+// eCoreRef = IORegistryEntryCreateCFProperty(obj, CFSTR("voltage-states1-sram"), kCFAllocatorDefault, 0);
//
// long long pCoreClock = getFrequency(pCoreRef);
// long long eCoreClock = getFrequency(eCoreRef);