File 4042-Rearrange-to-have-a-tighter-block-between-malloc-and.patch of Package erlang
From 31fe3af7978d62c87870c7b4d501c61fa02e37ff Mon Sep 17 00:00:00 2001
From: vlkrs <codeberg@schlecht.dev>
Date: Thu, 30 Mar 2023 18:19:01 +0200
Subject: [PATCH 2/2] Rearrange to have a tighter block between malloc() and
free()
---
lib/os_mon/c_src/cpu_sup.c | 10 +++++-----
1 file 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)
--
2.35.3