summaryrefslogtreecommitdiff
path: root/src/lib/meminfo/meminfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/meminfo/meminfo.c')
-rw-r--r--src/lib/meminfo/meminfo.c28
1 files changed, 3 insertions, 25 deletions
diff --git a/src/lib/meminfo/meminfo.c b/src/lib/meminfo/meminfo.c
index 0c5e0ed665..96f3cfc3cc 100644
--- a/src/lib/meminfo/meminfo.c
+++ b/src/lib/meminfo/meminfo.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2003-2004, Roger Dingledine
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2020, The Tor Project, Inc. */
+ * Copyright (c) 2007-2021, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -17,6 +17,7 @@
#include "lib/fs/files.h"
#include "lib/log/log.h"
#include "lib/malloc/malloc.h"
+#include "lib/string/util_string.h"
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
@@ -37,29 +38,6 @@
#include <sys/sysctl.h>
#endif
-DISABLE_GCC_WARNING("-Waggregate-return")
-/** Call the platform malloc info function, and dump the results to the log at
- * level <b>severity</b>. If no such function exists, do nothing. */
-void
-tor_log_mallinfo(int severity)
-{
-#ifdef HAVE_MALLINFO
- struct mallinfo mi;
- memset(&mi, 0, sizeof(mi));
- mi = mallinfo();
- tor_log(severity, LD_MM,
- "mallinfo() said: arena=%d, ordblks=%d, smblks=%d, hblks=%d, "
- "hblkhd=%d, usmblks=%d, fsmblks=%d, uordblks=%d, fordblks=%d, "
- "keepcost=%d",
- mi.arena, mi.ordblks, mi.smblks, mi.hblks,
- mi.hblkhd, mi.usmblks, mi.fsmblks, mi.uordblks, mi.fordblks,
- mi.keepcost);
-#else /* !defined(HAVE_MALLINFO) */
- (void)severity;
-#endif /* defined(HAVE_MALLINFO) */
-}
-ENABLE_GCC_WARNING("-Waggregate-return")
-
#if defined(HW_PHYSMEM64)
/* OpenBSD and NetBSD define this */
#define INT64_HW_MEM HW_PHYSMEM64
@@ -88,7 +66,7 @@ get_total_system_memory_impl(void)
s = read_file_to_str_until_eof(fd, 65536, &file_size);
if (!s)
goto err;
- cp = strstr(s, "MemTotal:");
+ cp = find_str_at_start_of_line(s, "MemTotal:");
if (!cp)
goto err;
/* Use the system sscanf so that space will match a wider number of space */