File: commit-863356a

package info (click to toggle)
rbldnsd 1.0~20210120-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 940 kB
  • sloc: ansic: 8,354; sh: 615; python: 614; makefile: 223; awk: 33
file content (56 lines) | stat: -rw-r--r-- 1,811 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
From 863356a55e71d88a073f503cff633f716b61c94d Mon Sep 17 00:00:00 2001
From: Michael Orlitzky <michael@orlitzky.com>
Date: Sun, 20 Nov 2022 17:27:13 -0500
Subject: [PATCH] configure,rbldnsd.c: replace mallinfo() with mallinfo2()

The mallinfo() function from malloc.h is deprecated, and has been
replaced by mallinfo2(). Additionally, the "mallinfo" struct that it
returns has been replaced by a "mallinfo2" struct. The only difference
between the two is that the newer struct contains members of type
size_t rather than int, which proved to be too small (leading to
overflows).

The call to ssprintf() that prints this information has been updated
to use the "z" length modifier, which is C99, but which is probably
safe by now. Other C99 features are already being used by rbldnsd.
---
 configure | 4 ++--
 rbldnsd.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index 3462b9a..6613caf 100755
--- a/configure
+++ b/configure
@@ -206,12 +206,12 @@ else
 fi
 fi # enable_ipv6?
 
-if ac_link_v "for mallinfo()" <<EOF
+if ac_link_v "for mallinfo2()" <<EOF
 #include <sys/types.h>
 #include <stdlib.h>
 #include <malloc.h>
 int main() {
-  struct mallinfo mi = mallinfo();
+  struct mallinfo2 mi = mallinfo2();
   return 0;
 }
 EOF
diff --git a/rbldnsd.c b/rbldnsd.c
index 2763577..92287f2 100644
--- a/rbldnsd.c
+++ b/rbldnsd.c
@@ -1187,10 +1187,10 @@ static int do_reload(int do_fork) {
 #endif /* NO_TIMES */
 #ifndef NO_MEMINFO
   {
-    struct mallinfo mi = mallinfo();
+    struct mallinfo2 mi = mallinfo2();
 # define kb(x) ((mi.x + 512)>>10)
     ip += ssprintf(ibuf + ip, sizeof(ibuf) - ip,
-          ", mem arena=%d free=%d mmap=%d Kb",
+          ", mem arena=%zd free=%zd mmap=%zd Kb",
           kb(arena), kb(fordblks), kb(hblkhd));
 # undef kb
   }