catclose.c revision 1.7
11.7Sjtc/*	$NetBSD: catclose.c,v 1.7 1996/05/13 23:29:37 jtc Exp $	*/
21.4Scgd
31.7Sjtc/*-
41.7Sjtc * Copyright (c) 1996 The NetBSD Foundation, Inc.
51.7Sjtc * All rights reserved.
61.7Sjtc *
71.7Sjtc * This code is derived from software contributed to The NetBSD Foundation
81.7Sjtc * by J.T. Conklin.
91.7Sjtc *
101.7Sjtc * Redistribution and use in source and binary forms, with or without
111.7Sjtc * modification, are permitted provided that the following conditions
121.7Sjtc * are met:
131.7Sjtc * 1. Redistributions of source code must retain the above copyright
141.7Sjtc *    notice, this list of conditions and the following disclaimer.
151.7Sjtc * 2. Redistributions in binary form must reproduce the above copyright
161.7Sjtc *    notice, this list of conditions and the following disclaimer in the
171.7Sjtc *    documentation and/or other materials provided with the distribution.
181.7Sjtc * 3. All advertising materials mentioning features or use of this software
191.7Sjtc *    must display the following acknowledgement:
201.7Sjtc *        This product includes software developed by the NetBSD
211.7Sjtc *        Foundation, Inc. and its contributors.
221.7Sjtc * 4. Neither the name of The NetBSD Foundation nor the names of its
231.7Sjtc *    contributors may be used to endorse or promote products derived
241.7Sjtc *    from this software without specific prior written permission.
251.7Sjtc *
261.7Sjtc * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
271.7Sjtc * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
281.7Sjtc * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
291.7Sjtc * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
301.7Sjtc * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
311.7Sjtc * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
321.7Sjtc * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
331.7Sjtc * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
341.7Sjtc * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
351.7Sjtc * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
361.7Sjtc * POSSIBILITY OF SUCH DAMAGE.
371.1Sjtc */
381.1Sjtc
391.7Sjtc#define _NLS_PRIVATE
401.1Sjtc
411.7Sjtc#include <sys/types.h>
421.7Sjtc#include <sys/mman.h>
431.7Sjtc#include <errno.h>
441.1Sjtc#include <nl_types.h>
451.1Sjtc
461.5Sjtcint
471.7Sjtc_catclose(catd)
481.1Sjtc	nl_catd catd;
491.1Sjtc{
501.7Sjtc	if (catd == (nl_catd) -1) {
511.7Sjtc		errno = EBADF;
521.7Sjtc		return -1;
531.7Sjtc	}
541.7Sjtc
551.7Sjtc	if (catd) {
561.7Sjtc		munmap(catd->__data, catd->__size);
571.7Sjtc		free (catd);
581.7Sjtc	}
591.7Sjtc
601.7Sjtc	return 0;
611.1Sjtc}
62