Hi tech@,

I am not a nitpicker. Though all memory will be reclaimed after process
exits, I still think it's a good habit to release all memory in heap.

Best Regards
Nan Xiao

Index: dmesg.c
===================================================================
RCS file: /cvs/src/sbin/dmesg/dmesg.c,v
retrieving revision 1.28
diff -u -p -r1.28 dmesg.c
--- dmesg.c 26 Aug 2017 08:53:20 -0000 1.28
+++ dmesg.c 31 Aug 2017 14:22:27 -0000
@@ -34,6 +34,7 @@
 #include <sys/msgbuf.h>
 #include <sys/sysctl.h>

+#include <stddef.h>
 #include <err.h>
 #include <fcntl.h>
 #include <kvm.h>
@@ -183,6 +184,14 @@ main(int argc, char *argv[])
  }
  if (!newl)
  putchar('\n');
+
+ if (memf == NULL && nlistf == NULL)
+ free(bufdata - offsetof(struct msgbuf, msg_bufc));
+ else {
+#ifndef NOKVM
+ free(bufdata);
+#endif
+ }
  return (0);
 }

Reply via email to