mutexblock.c revision 9ce781741ab32ce80c33a1f856d58691276310a0
5784N/A/*
5784N/A * Copyright (C) 1999, 2000 Internet Software Consortium.
5784N/A *
5784N/A * Permission to use, copy, modify, and distribute this software for any
5784N/A * purpose with or without fee is hereby granted, provided that the above
5784N/A * copyright notice and this permission notice appear in all copies.
5784N/A *
5784N/A * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
5784N/A * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
6982N/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
6982N/A * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
5784N/A * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
5784N/A * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
5784N/A * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
6982N/A * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
5784N/A */
6982N/A
6982N/A/* $Id: mutexblock.c,v 1.13 2000/08/29 00:25:23 bwelling Exp $ */
6982N/A
6982N/A#include <config.h>
5784N/A
5784N/A#include <isc/mutexblock.h>
5784N/A#include <isc/util.h>
5784N/A
5784N/Aisc_result_t
5784N/Aisc_mutexblock_init(isc_mutex_t *block, unsigned int count) {
5784N/A isc_result_t result;
5784N/A unsigned int i;
5784N/A
5784N/A for (i = 0 ; i < count ; i++) {
5784N/A result = isc_mutex_init(&block[i]);
5784N/A if (result != ISC_R_SUCCESS) {
5784N/A i--;
5784N/A while (i > 0) {
5784N/A DESTROYLOCK(&block[i]);
5784N/A i--;
5784N/A }
5784N/A return (result);
5784N/A }
5784N/A }
5784N/A
5784N/A return (ISC_R_SUCCESS);
5784N/A}
5784N/A
5784N/Aisc_result_t
5784N/Aisc_mutexblock_destroy(isc_mutex_t *block, unsigned int count) {
5784N/A isc_result_t result;
5784N/A unsigned int i;
5784N/A
5784N/A for (i = 0 ; i < count ; i++) {
5784N/A result = isc_mutex_destroy(&block[i]);
5784N/A if (result != ISC_R_SUCCESS)
5784N/A return (result);
5784N/A }
5784N/A
5784N/A return (ISC_R_SUCCESS);
5784N/A}
5784N/A