catclose.c revision 1.9
11.9Sjtc/*	$NetBSD: catclose.c,v 1.9 1997/07/30 23:49:45 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.9Sjtc * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
301.9Sjtc * BE 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.8Schristos#include "namespace.h"
421.7Sjtc#include <sys/types.h>
431.7Sjtc#include <sys/mman.h>
441.7Sjtc#include <errno.h>
451.8Schristos#include <stdlib.h>
461.1Sjtc#include <nl_types.h>
471.1Sjtc
481.5Sjtcint
491.7Sjtc_catclose(catd)
501.1Sjtc	nl_catd catd;
511.1Sjtc{
521.7Sjtc	if (catd == (nl_catd) -1) {
531.7Sjtc		errno = EBADF;
541.7Sjtc		return -1;
551.7Sjtc	}
561.7Sjtc
571.7Sjtc	if (catd) {
581.7Sjtc		munmap(catd->__data, catd->__size);
591.7Sjtc		free (catd);
601.7Sjtc	}
611.7Sjtc
621.7Sjtc	return 0;
631.1Sjtc}
64