mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-27 09:08:25 +00:00
freebsd: infallibly allocate 16B buffer on stack
there's no need to call calloc() for 16B, nor do we need to error-handle that allocation with exit()
This commit is contained in:
parent
7fa3d113da
commit
feb6a08537
@ -551,10 +551,9 @@ char get_freq(char *p_client_buffer, size_t client_buffer_size,
|
||||
return 0;
|
||||
}
|
||||
|
||||
freq_sysctl = (char *)calloc(16, sizeof(char));
|
||||
if (freq_sysctl == nullptr) { exit(-1); }
|
||||
char freq_sysctl[16] = {0};
|
||||
|
||||
snprintf(freq_sysctl, 16, "dev.cpu.%d.freq", (cpu - 1));
|
||||
snprintf(freq_sysctl, sizeof(freq_sysctl), "dev.cpu.%d.freq", (cpu - 1));
|
||||
|
||||
if (GETSYSCTL(freq_sysctl, freq) == 0) {
|
||||
snprintf(p_client_buffer, client_buffer_size, p_format,
|
||||
@ -563,7 +562,6 @@ char get_freq(char *p_client_buffer, size_t client_buffer_size,
|
||||
snprintf(p_client_buffer, client_buffer_size, p_format, 0.0f);
|
||||
}
|
||||
|
||||
free(freq_sysctl);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user