2 * Copyright (c) 2005 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.5 2005/12/22 19:05:42 ca Exp $")
14 ** Simple test program for memstat
27 int r, r2, i, l, slp, sz;
34 while ((r = getopt(argc, argv, "l:m:r:s:")) != -1)
39 l = strtol(optarg, NULL, 0);
43 sz = strtol(optarg, NULL, 0);
47 resource = strdup(optarg);
51 slp = strtol(optarg, NULL, 0);
59 r = sm_memstat_open();
61 for (i = 0; i < l; i++)
65 r2 = sm_memstat_get(resource, &v);
66 if (slp > 0 && i + 1 < l && 0 == r)
68 printf("open=%d, memstat=%d, %s=%ld\n", r, r2,
69 resource != NULL ? resource : "default-value",
75 ** Just allocate some memory to test the
76 ** values that are returned.
77 ** Note: this is a memory leak, but that
78 ** doesn't matter here.
83 printf("malloc(%d) failed\n", sz);
87 printf("open=%d, memstat=%d, %s=%ld\n", r, r2,
88 resource != NULL ? resource : "default-value", v);
89 r = sm_memstat_close();