[optimization] pass by value instead of global values
This commit is contained in:
parent
e0a44b9c2b
commit
123e2a77c8
24
source/lib.c
24
source/lib.c
@ -27,17 +27,24 @@ void av_mem_size();
|
|||||||
void device_up_time();
|
void device_up_time();
|
||||||
void device_os_version();
|
void device_os_version();
|
||||||
void device_hostname();
|
void device_hostname();
|
||||||
|
void device_model();
|
||||||
|
|
||||||
cpu_s _cpu;
|
void init_device();
|
||||||
ram_s _ram;
|
|
||||||
disk_s _disk;
|
|
||||||
device_s _device;
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __gnu_linux__
|
#ifdef __gnu_linux__
|
||||||
|
|
||||||
#include <sys/sysinfo.h>
|
#include <sys/sysinfo.h>
|
||||||
|
|
||||||
|
void init_device() {
|
||||||
|
|
||||||
|
device_s _device;
|
||||||
|
|
||||||
|
_device.&name = device_model();
|
||||||
|
_device.&hostname =
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void cpu_name(){
|
void cpu_name(){
|
||||||
int buffer_size = 256;
|
int buffer_size = 256;
|
||||||
char cpu_name[buffer_size];
|
char cpu_name[buffer_size];
|
||||||
@ -329,6 +336,15 @@ void device_os_version() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void init_device() {
|
||||||
|
|
||||||
|
device_s _device;
|
||||||
|
|
||||||
|
_device.name = device_model();
|
||||||
|
_device.hostname =
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
#ifndef LIB_H
|
#ifndef LIB_H
|
||||||
#define LIB_H
|
#define LIB_H
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
|
||||||
void cpu_name();
|
void cpu_name(cpu_s cpu);
|
||||||
void cpu_threads();
|
void cpu_threads();
|
||||||
void cpu_temperature();
|
void cpu_temperature();
|
||||||
void cpu_frequency();
|
void cpu_frequency();
|
||||||
|
|||||||
@ -21,9 +21,17 @@ typedef struct {
|
|||||||
} disk_s;
|
} disk_s;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char* name;
|
|
||||||
char* hostname;
|
char *name;
|
||||||
char* os_version;
|
char *hostname;
|
||||||
|
char *os_version;
|
||||||
|
int uptime;
|
||||||
|
cpu_s cpu;
|
||||||
|
ram_s ram;
|
||||||
|
disk_s disk;
|
||||||
|
|
||||||
|
|
||||||
} device_s;
|
} device_s;
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user