8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / sendmail / libsm / t-heap.c
blob290b07e17f2b95785dd63550c0a4659d576af1ce
1 /*
2 * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
8 */
10 #pragma ident "%Z%%M% %I% %E% SMI"
12 #include <sm/gen.h>
13 SM_IDSTR(id, "@(#)$Id: t-heap.c,v 1.8 2001/03/06 17:27:36 ca Exp $")
15 #include <sm/debug.h>
16 #include <sm/heap.h>
17 #include <sm/io.h>
18 #include <sm/test.h>
19 #include <sm/xtrap.h>
21 #if SM_HEAP_CHECK
22 extern SM_DEBUG_T SmHeapCheck;
23 # define HEAP_CHECK sm_debug_active(&SmHeapCheck, 1)
24 #else /* SM_HEAP_CHECK */
25 # define HEAP_CHECK 0
26 #endif /* SM_HEAP_CHECK */
28 int
29 main(argc, argv)
30 int argc;
31 char **argv;
33 void *p;
35 sm_test_begin(argc, argv, "test heap handling");
36 if (argc > 1)
37 sm_debug_addsettings_x(argv[1]);
39 p = sm_malloc(10);
40 SM_TEST(p != NULL);
41 p = sm_realloc_x(p, 20);
42 SM_TEST(p != NULL);
43 p = sm_realloc(p, 30);
44 SM_TEST(p != NULL);
45 if (HEAP_CHECK)
47 sm_dprintf("heap with 1 30-byte block allocated:\n");
48 sm_heap_report(smioout, 3);
51 if (HEAP_CHECK)
53 sm_free(p);
54 sm_dprintf("heap with 0 blocks allocated:\n");
55 sm_heap_report(smioout, 3);
56 sm_dprintf("xtrap count = %d\n", SmXtrapCount);
59 #if DEBUG
60 /* this will cause a core dump */
61 sm_dprintf("about to free %p for the second time\n", p);
62 sm_free(p);
63 #endif /* DEBUG */
65 return sm_test_end();