mempool_test.c revision bf7c02293f883118784f7952944fa3e2bce98078
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Copyright (C) 1999, 2000 Internet Software Consortium.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Permission to use, copy, modify, and distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * purpose with or without fee is hereby granted, provided that the above
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * copyright notice and this permission notice appear in all copies.
e45d0508c3460db87afb1f743bc5210522721bb3Evan Hunt * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
e45d0508c3460db87afb1f743bc5210522721bb3Evan Hunt * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
e45d0508c3460db87afb1f743bc5210522721bb3Evan Hunt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
e45d0508c3460db87afb1f743bc5210522721bb3Evan Hunt * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
aa7b16ec2a5dacda1d65b64e0f7af434d02cbba4Tinderbox User * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
e45d0508c3460db87afb1f743bc5210522721bb3Evan Hunt * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
e45d0508c3460db87afb1f743bc5210522721bb3Evan Hunt * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
e45d0508c3460db87afb1f743bc5210522721bb3Evan Hunt * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
e45d0508c3460db87afb1f743bc5210522721bb3Evan Hunt/* $Id: mempool_test.c,v 1.11 2000/08/30 01:35:37 bwelling Exp $ */
e45d0508c3460db87afb1f743bc5210522721bb3Evan Hunt unsigned int i, j;
e45d0508c3460db87afb1f743bc5210522721bb3Evan Hunt RUNTIME_CHECK(isc_mutex_init(&lock) == ISC_R_SUCCESS);
e45d0508c3460db87afb1f743bc5210522721bb3Evan Hunt RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
aa7b16ec2a5dacda1d65b64e0f7af434d02cbba4Tinderbox User RUNTIME_CHECK(isc_mempool_create(mctx, 24, &mp1) == ISC_R_SUCCESS);
e45d0508c3460db87afb1f743bc5210522721bb3Evan Hunt RUNTIME_CHECK(isc_mempool_create(mctx, 31, &mp2) == ISC_R_SUCCESS);
e45d0508c3460db87afb1f743bc5210522721bb3Evan Hunt * Allocate 30 items from the pool. This is our max.
aa7b16ec2a5dacda1d65b64e0f7af434d02cbba4Tinderbox User for (i = 0 ; i < 30 ; i++) {
e45d0508c3460db87afb1f743bc5210522721bb3Evan Hunt * Try to allocate one more. This should fail.
e45d0508c3460db87afb1f743bc5210522721bb3Evan Hunt * Free the first 11 items. Verify that there are 10 free items on
aa7b16ec2a5dacda1d65b64e0f7af434d02cbba4Tinderbox User * the free list (which is our max).