summaryrefslogtreecommitdiff
path: root/devel/dwarves/files/patch-dtagnames.c
blob: b8c8e0d4debb74ad7f9704a51f76bff278965099 (plain) (blame)
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
--- dtagnames.c.orig	2019-05-01 15:06:45 UTC
+++ dtagnames.c
@@ -7,16 +7,31 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <malloc.h>
+#ifdef __FreeBSD__
+#include <err.h>
+#include <malloc_np.h>
+#else
+#endif
 
 #include "dwarves.h"
 #include "dutil.h"
 
 static void print_malloc_stats(void)
 {
+#ifdef __FreeBSD__
+	int error;
+	size_t allocated, sz;
+
+	sz = sizeof(allocated);
+	error = mallctl("stats.active", &allocated, &sz, NULL, 0);
+	if (error != 0)
+		errc(1, error, "mallctl(stats.active)");
+	fprintf(stderr, "size: %zu\n", allocated);
+#else
 	struct mallinfo m = mallinfo();
 
 	fprintf(stderr, "size: %u\n", m.uordblks);
+#endif
 }
 
 static int class__tag_name(struct tag *tag, struct cu *cu __unused,