Revision 19204,
1.3 KB
checked in by zacheiss, 22 years ago
(diff) |
This commit was generated by cvs2svn to compensate for changes in r19203,
which included commits to RCS files with non-trunk default branches.
|
Line | |
---|
1 | /* |
---|
2 | * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers. |
---|
3 | * All rights reserved. |
---|
4 | * |
---|
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 | */ |
---|
9 | |
---|
10 | #include <sm/gen.h> |
---|
11 | SM_IDSTR(id, "@(#)$Id: t-heap.c,v 1.1.1.1 2003-04-08 15:06:05 zacheiss Exp $") |
---|
12 | |
---|
13 | #include <sm/debug.h> |
---|
14 | #include <sm/heap.h> |
---|
15 | #include <sm/io.h> |
---|
16 | #include <sm/test.h> |
---|
17 | #include <sm/xtrap.h> |
---|
18 | |
---|
19 | #if SM_HEAP_CHECK |
---|
20 | extern SM_DEBUG_T SmHeapCheck; |
---|
21 | # define HEAP_CHECK sm_debug_active(&SmHeapCheck, 1) |
---|
22 | #else /* SM_HEAP_CHECK */ |
---|
23 | # define HEAP_CHECK 0 |
---|
24 | #endif /* SM_HEAP_CHECK */ |
---|
25 | |
---|
26 | int |
---|
27 | main(argc, argv) |
---|
28 | int argc; |
---|
29 | char **argv; |
---|
30 | { |
---|
31 | void *p; |
---|
32 | |
---|
33 | sm_test_begin(argc, argv, "test heap handling"); |
---|
34 | if (argc > 1) |
---|
35 | sm_debug_addsettings_x(argv[1]); |
---|
36 | |
---|
37 | p = sm_malloc(10); |
---|
38 | SM_TEST(p != NULL); |
---|
39 | p = sm_realloc_x(p, 20); |
---|
40 | SM_TEST(p != NULL); |
---|
41 | p = sm_realloc(p, 30); |
---|
42 | SM_TEST(p != NULL); |
---|
43 | if (HEAP_CHECK) |
---|
44 | { |
---|
45 | sm_dprintf("heap with 1 30-byte block allocated:\n"); |
---|
46 | sm_heap_report(smioout, 3); |
---|
47 | } |
---|
48 | |
---|
49 | if (HEAP_CHECK) |
---|
50 | { |
---|
51 | sm_free(p); |
---|
52 | sm_dprintf("heap with 0 blocks allocated:\n"); |
---|
53 | sm_heap_report(smioout, 3); |
---|
54 | sm_dprintf("xtrap count = %d\n", SmXtrapCount); |
---|
55 | } |
---|
56 | |
---|
57 | #if DEBUG |
---|
58 | /* this will cause a core dump */ |
---|
59 | sm_dprintf("about to free %p for the second time\n", p); |
---|
60 | sm_free(p); |
---|
61 | #endif /* DEBUG */ |
---|
62 | |
---|
63 | return sm_test_end(); |
---|
64 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.