summaryrefslogtreecommitdiff
path: root/lib/os_mon
diff options
context:
space:
mode:
authorvlkrs <codeberg@schlecht.dev>2023-03-30 18:19:01 +0200
committervlkrs <codeberg@schlecht.dev>2023-03-30 18:19:01 +0200
commit31fe3af7978d62c87870c7b4d501c61fa02e37ff (patch)
treefe4e729b23d9d601e9edd4fd7ad0685328025cf7 /lib/os_mon
parent259ef22b495fac794246c6cb5fc6b2aa8a65ba52 (diff)
downloaderlang-31fe3af7978d62c87870c7b4d501c61fa02e37ff.tar.gz
Rearrange to have a tighter block between malloc() and free()
Diffstat (limited to 'lib/os_mon')
-rw-r--r--lib/os_mon/c_src/cpu_sup.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/os_mon/c_src/cpu_sup.c b/lib/os_mon/c_src/cpu_sup.c
index 8e8e3a32f5..884af41157 100644
--- a/lib/os_mon/c_src/cpu_sup.c
+++ b/lib/os_mon/c_src/cpu_sup.c
@@ -766,17 +766,17 @@ static void util_measure(unsigned int **result_vec, int *result_sz) {
int i;
int ncpuonline = getncpuonline();
- size_cpu_times = sizeof(int64_t) * CPUSTATES;
- cpu_times = malloc(size_cpu_times);
- if (!cpu_times)
- error("cpu_sup: malloc error");
-
rv = *result_vec;
rv[0] = ncpuonline;
rv[1] = CU_OPENBSD_VALUES;
++rv; /* first value is number of cpus */
++rv; /* second value is number of entries */
+ size_cpu_times = sizeof(int64_t) * CPUSTATES;
+ cpu_times = malloc(size_cpu_times);
+ if (!cpu_times)
+ error("cpu_sup: malloc error");
+
for (i = 0; i < ncpuonline; ++i) {
mib[2] = i;
if (sysctl(mib, sizeof(mib)/sizeof(mib[0]), cpu_times, &size_cpu_times, NULL, 0) == -1)