2 * Copyright (c) 2005, 2006 Sendmail, Inc. and its suppliers.
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.
11 SM_IDSTR(id, "@(#)$Id: t-memstat.c,v 1.6 2006/03/27 22:34:47 ca Exp $")
14 ** Simple test program for memstat
31 int r, r2, i, l, slp, sz;
38 while ((r = getopt(argc, argv, "l:m:r:s:")) != -1)
43 l = strtol(optarg, NULL, 0);
47 sz = strtol(optarg, NULL, 0);
51 resource = strdup(optarg);
55 slp = strtol(optarg, NULL, 0);
63 r = sm_memstat_open();
65 for (i = 0; i < l; i++)
69 r2 = sm_memstat_get(resource, &v);
70 if (slp > 0 && i + 1 < l && 0 == r)
72 printf("open=%d, memstat=%d, %s=%ld\n", r, r2,
73 resource != NULL ? resource : "default-value",
79 ** Just allocate some memory to test the
80 ** values that are returned.
81 ** Note: this is a memory leak, but that
82 ** doesn't matter here.
87 printf("malloc(%d) failed\n", sz);
91 printf("open=%d, memstat=%d, %s=%ld\n", r, r2,
92 resource != NULL ? resource : "default-value", v);
93 r = sm_memstat_close();