alloc.c revision 1.9
11.9Sdholland/* $NetBSD: alloc.c,v 1.9 2011/08/06 20:18:26 dholland Exp $ */ 21.5Sjsm 31.5Sjsm/* 41.5Sjsm * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, 51.5Sjsm * Amsterdam 61.5Sjsm * All rights reserved. 71.5Sjsm * 81.5Sjsm * Redistribution and use in source and binary forms, with or without 91.5Sjsm * modification, are permitted provided that the following conditions are 101.5Sjsm * met: 111.5Sjsm * 121.5Sjsm * - Redistributions of source code must retain the above copyright notice, 131.5Sjsm * this list of conditions and the following disclaimer. 141.5Sjsm * 151.5Sjsm * - Redistributions in binary form must reproduce the above copyright 161.5Sjsm * notice, this list of conditions and the following disclaimer in the 171.5Sjsm * documentation and/or other materials provided with the distribution. 181.5Sjsm * 191.5Sjsm * - Neither the name of the Stichting Centrum voor Wiskunde en 201.5Sjsm * Informatica, nor the names of its contributors may be used to endorse or 211.5Sjsm * promote products derived from this software without specific prior 221.5Sjsm * written permission. 231.5Sjsm * 241.5Sjsm * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 251.5Sjsm * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 261.5Sjsm * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 271.5Sjsm * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 281.5Sjsm * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 291.5Sjsm * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 301.5Sjsm * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 311.5Sjsm * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 321.5Sjsm * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 331.5Sjsm * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 341.5Sjsm * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 351.5Sjsm */ 361.5Sjsm 371.5Sjsm/* 381.5Sjsm * Copyright (c) 1982 Jay Fenlason <hack@gnu.org> 391.5Sjsm * All rights reserved. 401.5Sjsm * 411.5Sjsm * Redistribution and use in source and binary forms, with or without 421.5Sjsm * modification, are permitted provided that the following conditions 431.5Sjsm * are met: 441.5Sjsm * 1. Redistributions of source code must retain the above copyright 451.5Sjsm * notice, this list of conditions and the following disclaimer. 461.5Sjsm * 2. Redistributions in binary form must reproduce the above copyright 471.5Sjsm * notice, this list of conditions and the following disclaimer in the 481.5Sjsm * documentation and/or other materials provided with the distribution. 491.5Sjsm * 3. The name of the author may not be used to endorse or promote products 501.5Sjsm * derived from this software without specific prior written permission. 511.5Sjsm * 521.5Sjsm * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 531.5Sjsm * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 541.5Sjsm * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 551.5Sjsm * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 561.5Sjsm * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 571.5Sjsm * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 581.5Sjsm * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 591.5Sjsm * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 601.5Sjsm * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 611.5Sjsm * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 621.5Sjsm */ 631.5Sjsm 641.4Schristos#include <sys/cdefs.h> 651.2Smycroft#ifndef lint 661.9Sdholland__RCSID("$NetBSD: alloc.c,v 1.9 2011/08/06 20:18:26 dholland Exp $"); 671.4Schristos#endif /* not lint */ 681.4Schristos 691.4Schristos#include <stdlib.h> 701.4Schristos#include "hack.h" 711.4Schristos#include "extern.h" 721.2Smycroft 731.9Sdhollandvoid * 741.9Sdhollandalloc(size_t len) 751.1Scgd{ 761.9Sdholland void *ptr; 771.1Scgd 781.9Sdholland ptr = malloc(len); 791.9Sdholland if (ptr == NULL) 801.9Sdholland panic("Cannot get %zu bytes", len); 811.9Sdholland return ptr; 821.1Scgd} 831.1Scgd 841.7Sdholland#if 0 /* unused */ 851.7Sdhollandstatic long * 861.6Sdhollandenlarge(char *ptr, unsigned lth) 871.1Scgd{ 881.4Schristos char *nptr; 891.1Scgd 901.4Schristos if (!(nptr = realloc(ptr, lth))) 911.1Scgd panic("Cannot reallocate %d bytes", lth); 921.4Schristos return ((long *) nptr); 931.1Scgd} 941.7Sdholland#endif 95