fix macOS build/resource ownership

This commit is contained in:
deepend committed 2026-12-04 18:30:22 -06:00
1 parent 5c8036ad80
commit 81709c7235
3 files changed
+22 -14

No files matched your search

+1 -1
View File
@@ -67,7 +67,7 @@ option('with-python', type: 'string', value: 'python3',
description: 'Python scripting plugin. value is pkg-config name to use or "false"' description: 'Python scripting plugin. value is pkg-config name to use or "false"'
) )
option('with-sysinfo', type: 'boolean', option('with-sysinfo', type: 'boolean',
description: 'System information plugin, requires libpci on Unix' description: 'System information plugin (optional libpci for PCI names on Unix)'
) )
option('with-upd', type: 'boolean', option('with-upd', type: 'boolean',
description: 'Update plugin, Windows only' description: 'Update plugin, Windows only'
+1
View File
@@ -54,6 +54,7 @@ elif system == 'darwin'
sysinfo_includes += 'shared' sysinfo_includes += 'shared'
sysinfo_sources += 'shared/df.c' sysinfo_sources += 'shared/df.c'
add_languages('objc') add_languages('objc')
sysinfo_deps += dependency('appleframeworks', modules: ['Cocoa', 'IOKit'])
sysinfo_sources += 'osx/backend.m' sysinfo_sources += 'osx/backend.m'
elif system == 'windows' elif system == 'windows'
+20 -13
View File
@@ -23,6 +23,8 @@
*/ */
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#include <IOKit/IOKitLib.h>
#include <string.h>
#include <sys/sysctl.h> #include <sys/sysctl.h>
#include <mach/mach.h> #include <mach/mach.h>
@@ -38,6 +40,7 @@
#include "format.h" #include "format.h"
#include "df.h" #include "df.h"
#include "sysinfo-backend.h"
static char * static char *
get_os (void) get_os (void)
@@ -48,10 +51,7 @@ get_os (void)
return NULL; return NULL;
NSString *version = [systemversion objectForKey:@"ProductUserVisibleVersion"]; NSString *version = [systemversion objectForKey:@"ProductUserVisibleVersion"];
if (!version) if (!version)
{
[build release];
return NULL; return NULL;
}
NSDictionary *profiler = [NSDictionary dictionaryWithContentsOfFile:[@"~/Library/Preferences/com.apple.SystemProfiler.plist" stringByExpandingTildeInPath]]; NSDictionary *profiler = [NSDictionary dictionaryWithContentsOfFile:[@"~/Library/Preferences/com.apple.SystemProfiler.plist" stringByExpandingTildeInPath]];
NSDictionary *names = [profiler objectForKey:@"OS Names"]; NSDictionary *names = [profiler objectForKey:@"OS Names"];
@@ -65,18 +65,11 @@ get_os (void)
break; break;
} }
} }
[build release]; /* Dictionary values are borrowed; releasing them would over-release. */
if (!os_name) if (!os_name)
{
[version release];
return NULL; return NULL;
}
char *ret = g_strdup_printf ("%s %s", [os_name UTF8String], [version UTF8String]); return g_strdup_printf ("%s %s", [os_name UTF8String], [version UTF8String]);
[version release];
return ret;
} }
static char * static char *
@@ -219,9 +212,14 @@ get_gpu(void)
} }
const void *class = CFDictionaryGetValue(serviceDictionary, @"class-code"); const void *class = CFDictionaryGetValue(serviceDictionary, @"class-code");
if (!class || *(guint32*)CFDataGetBytePtr(class) != 0x30000) /* DISPLAY_VGA */ guint32 class_code = 0;
if (class && CFGetTypeID (class) == CFDataGetTypeID () &&
CFDataGetLength (class) >= sizeof (class_code))
memcpy (&class_code, CFDataGetBytePtr (class), sizeof (class_code));
if (GUINT32_FROM_LE (class_code) != 0x30000) /* DISPLAY_VGA */
{ {
CFRelease(serviceDictionary); CFRelease(serviceDictionary);
IOObjectRelease (serviceObject);
continue; continue;
} }
@@ -237,7 +235,9 @@ get_gpu(void)
} }
CFRelease(serviceDictionary); CFRelease(serviceDictionary);
IOObjectRelease (serviceObject);
} }
IOObjectRelease (entry_iterator);
if (gpu_list->len == 0) if (gpu_list->len == 0)
{ {
@@ -265,6 +265,13 @@ sysinfo_backend_get_gpu(void)
return g_strdup (gpu_str); return g_strdup (gpu_str);
} }
char *
sysinfo_backend_get_chipset (void)
{
/* No chipset detector exists in the legacy macOS backend. */
return NULL;
}
char * char *
sysinfo_backend_get_sound(void) sysinfo_backend_get_sound(void)
{ {