summaryrefslogtreecommitdiff
path: root/gnu/usr.sbin/sendmail/libsm/t-heap.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2001-09-11 18:55:53 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2001-09-11 18:55:53 +0000
commit4643c616c81fb1198b29c3eaff4d697392c8dc4b (patch)
tree4afa26a5f1a2ef0e47061eb08b6d339bc7e8dad1 /gnu/usr.sbin/sendmail/libsm/t-heap.c
parent8afe339a41c898cc4a2d42d03d115b16f2053bad (diff)
sendmail 8.12.0 with $Id tags converted to $Sendmail
Diffstat (limited to 'gnu/usr.sbin/sendmail/libsm/t-heap.c')
-rw-r--r--gnu/usr.sbin/sendmail/libsm/t-heap.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/gnu/usr.sbin/sendmail/libsm/t-heap.c b/gnu/usr.sbin/sendmail/libsm/t-heap.c
new file mode 100644
index 00000000000..e4fea360966
--- /dev/null
+++ b/gnu/usr.sbin/sendmail/libsm/t-heap.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set
+ * forth in the LICENSE file which can be found at the top level of
+ * the sendmail distribution.
+ */
+
+#include <sm/gen.h>
+SM_IDSTR(id, "@(#)$Sendmail: t-heap.c,v 1.8 2001/03/06 17:27:36 ca Exp $")
+
+#include <sm/debug.h>
+#include <sm/heap.h>
+#include <sm/io.h>
+#include <sm/test.h>
+#include <sm/xtrap.h>
+
+#if SM_HEAP_CHECK
+extern SM_DEBUG_T SmHeapCheck;
+# define HEAP_CHECK sm_debug_active(&SmHeapCheck, 1)
+#else /* SM_HEAP_CHECK */
+# define HEAP_CHECK 0
+#endif /* SM_HEAP_CHECK */
+
+int
+main(argc, argv)
+ int argc;
+ char **argv;
+{
+ void *p;
+
+ sm_test_begin(argc, argv, "test heap handling");
+ if (argc > 1)
+ sm_debug_addsettings_x(argv[1]);
+
+ p = sm_malloc(10);
+ SM_TEST(p != NULL);
+ p = sm_realloc_x(p, 20);
+ SM_TEST(p != NULL);
+ p = sm_realloc(p, 30);
+ SM_TEST(p != NULL);
+ if (HEAP_CHECK)
+ {
+ sm_dprintf("heap with 1 30-byte block allocated:\n");
+ sm_heap_report(smioout, 3);
+ }
+
+ if (HEAP_CHECK)
+ {
+ sm_free(p);
+ sm_dprintf("heap with 0 blocks allocated:\n");
+ sm_heap_report(smioout, 3);
+ sm_dprintf("xtrap count = %d\n", SmXtrapCount);
+ }
+
+#if DEBUG
+ /* this will cause a core dump */
+ sm_dprintf("about to free %p for the second time\n", p);
+ sm_free(p);
+#endif /* DEBUG */
+
+ return sm_test_end();
+}