Commit Graph

4 Commits (b7932a9266933093e42a91a46b532dd769770698)

Author SHA1 Message Date
uubulb 1f39525d2d refactor(darwin): optimize string allocation 3 months ago
Li Chuangbo 19082b35ae
fix: memory leak and string corruption in ARM Mac temperature sensors
This commit addresses several issues in the temperature sensor implementation for ARM Mac:
1. Memory leak caused by unreleased system resources
2. Increasing port counts in Activity Monitor
3. String corruption where the first character becomes "\x00"

Changes:

1. Resource Management:
   - Added proper resource cleanup using `defer` statements
   - Refactored code to share the HID system client instead of creating new ones
   - Fixed memory leaks by ensuring all CoreFoundation objects are properly released

2. String Handling:
   - Fixed buffer allocation for string conversion
   - Properly handle null terminators in C string to Go string conversion
   - Added correct string length calculations

3. Code Structure:
   - Reduced resource allocation by sharing system client between functions
   - Enhanced code readability with better comments
3 months ago
uubulb 10d9c04c2e sensors: avoid passing nil pointer to CFArrayGetCount 5 months ago
uubulb 701a74be41 feat(cpu, mem, sensors)(darwin): cgo-free implementations 6 months ago