1202719Sgabor/* 2265533Sdelphij * Copyright (c) 1999 - 2001 Kungliga Tekniska H��gskolan 3202719Sgabor * (Royal Institute of Technology, Stockholm, Sweden). 4202719Sgabor * All rights reserved. 5202719Sgabor * 6202719Sgabor * Redistribution and use in source and binary forms, with or without 7202719Sgabor * modification, are permitted provided that the following conditions 8202719Sgabor * are met: 9202719Sgabor * 10202719Sgabor * 1. Redistributions of source code must retain the above copyright 11202719Sgabor * notice, this list of conditions and the following disclaimer. 12202719Sgabor * 13202719Sgabor * 2. Redistributions in binary form must reproduce the above copyright 14202719Sgabor * notice, this list of conditions and the following disclaimer in the 15202719Sgabor * documentation and/or other materials provided with the distribution. 16202719Sgabor * 17202719Sgabor * 3. Neither the name of the Institute nor the names of its contributors 18202719Sgabor * may be used to endorse or promote products derived from this software 19202719Sgabor * without specific prior written permission. 20202719Sgabor * 21202719Sgabor * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 22202719Sgabor * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23202719Sgabor * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24202719Sgabor * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 25202719Sgabor * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26202719Sgabor * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27202719Sgabor * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28202719Sgabor * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29202719Sgabor * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30202719Sgabor * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31202719Sgabor * SUCH DAMAGE. 32202719Sgabor */ 33202719Sgabor 34202719Sgabor#include <config.h> 35202719Sgabor 36202719Sgabor#include <stdlib.h> 37202719Sgabor#include <err.h> 38202719Sgabor 39202719Sgabor#include "roken.h" 40202719Sgabor 41202719Sgabor/* 42202719Sgabor * Like calloc but never fails. 43202719Sgabor */ 44202719Sgabor 45202719SgaborROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL 46202719Sgaborecalloc (size_t number, size_t size) 47202719Sgabor{ 48202719Sgabor void *tmp = calloc (number, size); 49202719Sgabor 50202719Sgabor if (tmp == NULL && number * size != 0) 51202719Sgabor errx (1, "calloc %lu failed", (unsigned long)number * size); 52202719Sgabor return tmp; 53202719Sgabor} 54202719Sgabor