From 4643c616c81fb1198b29c3eaff4d697392c8dc4b Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 11 Sep 2001 18:55:53 +0000 Subject: sendmail 8.12.0 with $Id tags converted to $Sendmail --- gnu/usr.sbin/sendmail/libsm/t-heap.c | 64 ++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 gnu/usr.sbin/sendmail/libsm/t-heap.c (limited to 'gnu/usr.sbin/sendmail/libsm/t-heap.c') 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_IDSTR(id, "@(#)$Sendmail: t-heap.c,v 1.8 2001/03/06 17:27:36 ca Exp $") + +#include +#include +#include +#include +#include + +#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(); +} -- cgit v1.2.3