catclose.c revision 1.14
11.14Sabs/* $NetBSD: catclose.c,v 1.14 2012/06/25 22:32:45 abs 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 * 191.7Sjtc * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201.7Sjtc * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211.7Sjtc * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221.9Sjtc * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231.9Sjtc * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241.7Sjtc * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251.7Sjtc * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261.7Sjtc * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271.7Sjtc * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 281.7Sjtc * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291.7Sjtc * POSSIBILITY OF SUCH DAMAGE. 301.1Sjtc */ 311.1Sjtc 321.12Slukem#include <sys/cdefs.h> 331.12Slukem#if defined(LIBC_SCCS) && !defined(lint) 341.14Sabs__RCSID("$NetBSD: catclose.c,v 1.14 2012/06/25 22:32:45 abs Exp $"); 351.12Slukem#endif /* LIBC_SCCS and not lint */ 361.12Slukem 371.7Sjtc#define _NLS_PRIVATE 381.1Sjtc 391.8Schristos#include "namespace.h" 401.7Sjtc#include <sys/types.h> 411.7Sjtc#include <sys/mman.h> 421.7Sjtc#include <errno.h> 431.8Schristos#include <stdlib.h> 441.1Sjtc#include <nl_types.h> 451.11Smycroft 461.11Smycroft#ifdef __weak_alias 471.11Smycroft__weak_alias(catclose, _catclose) 481.11Smycroft#endif 491.1Sjtc 501.5Sjtcint 511.14Sabs_catclose(nl_catd catd) 521.1Sjtc{ 531.7Sjtc if (catd == (nl_catd) -1) { 541.7Sjtc errno = EBADF; 551.7Sjtc return -1; 561.7Sjtc } 571.7Sjtc 581.7Sjtc if (catd) { 591.10Schristos munmap(catd->__data, (size_t)catd->__size); 601.7Sjtc free (catd); 611.7Sjtc } 621.7Sjtc 631.7Sjtc return 0; 641.1Sjtc} 65