daisydog: trim heaps once we finished initializing

We can tell glibc to release any excess memory it allocated once we
hit the main loop as this loop is small and should never really do
any more malloc.  A minor optimization.

BUG=None
TEST=CQ passes

Change-Id: I10f20e5d816392e41857a2a4f903b0838cb8b0ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/daisydog/+/2657814
Tested-by: Mike Frysinger <vapier@chromium.org>
Auto-Submit: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Grant Grundler <grundler@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
diff --git a/daisydog.c b/daisydog.c
index 77e087d..12df2fe 100644
--- a/daisydog.c
+++ b/daisydog.c
@@ -27,6 +27,7 @@
 #include <sys/ioctl.h>
 #include <fcntl.h>
 #include <getopt.h>
+#include <malloc.h>
 #include <string.h>
 #include <signal.h>
 #include <errno.h>
@@ -175,6 +176,9 @@
 		err(EXIT_FAILURE, "%s: cannot read boot status", dev);
 	}
 
+	/* Before we start the main loop, release any caches we don't need. */
+	malloc_trim(0);
+
 	/* There are two ways to pet the watchdog:
 	 * 1) by writing any dummy value into watchdog device file, or
 	 * 2) by using IOCTL WDIOC_KEEPALIVE