1N/A/*
1N/A * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers.
1N/A * All rights reserved.
1N/A *
1N/A * By using this file, you agree to the terms and conditions set
1N/A * forth in the LICENSE file which can be found at the top level of
1N/A * the sendmail distribution.
1N/A */
1N/A
1N/A#pragma ident "%Z%%M% %I% %E% SMI"
1N/A
1N/A#include <sm/gen.h>
1N/ASM_IDSTR(id, "@(#)$Id: t-rpool.c,v 1.16 2001/03/04 18:38:47 ca Exp $")
1N/A
1N/A#include <sm/debug.h>
1N/A#include <sm/heap.h>
1N/A#include <sm/rpool.h>
1N/A#include <sm/io.h>
1N/A#include <sm/test.h>
1N/A
1N/Astatic void
1N/Arfree __P((
1N/A void *cx));
1N/A
1N/Astatic void
1N/Arfree(cx)
1N/A void *cx;
1N/A{
1N/A (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "rfree freeing `%s'\n",
1N/A (char *) cx);
1N/A}
1N/A
1N/Aint
1N/Amain(argc, argv)
1N/A int argc;
1N/A char *argv[];
1N/A{
1N/A SM_RPOOL_T *rpool;
1N/A char *a[26];
1N/A int i, j;
1N/A SM_RPOOL_ATTACH_T att;
1N/A
1N/A sm_test_begin(argc, argv, "test rpool");
1N/A sm_debug_addsetting_x("sm_check_heap", 1);
1N/A rpool = sm_rpool_new_x(NULL);
1N/A SM_TEST(rpool != NULL);
1N/A att = sm_rpool_attach_x(rpool, rfree, "attachment #1");
1N/A SM_TEST(att != NULL);
1N/A for (i = 0; i < 26; ++i)
1N/A {
1N/A size_t sz = i * i * i;
1N/A
1N/A a[i] = sm_rpool_malloc_x(rpool, sz);
1N/A for (j = 0; j < sz; ++j)
1N/A a[i][j] = 'a' + i;
1N/A }
1N/A att = sm_rpool_attach_x(rpool, rfree, "attachment #2");
1N/A (void) sm_rpool_attach_x(rpool, rfree, "attachment #3");
1N/A sm_rpool_detach(att);
1N/A
1N/A /* XXX more tests? */
1N/A#if DEBUG
1N/A sm_dprintf("heap after filling up rpool:\n");
1N/A sm_heap_report(smioout, 3);
1N/A sm_dprintf("freeing rpool:\n");
1N/A sm_rpool_free(rpool);
1N/A sm_dprintf("heap after freeing rpool:\n");
1N/A sm_heap_report(smioout, 3);
1N/A#endif /* DEBUG */
1N/A return sm_test_end();
1N/A}