14ecbd6dmarkm/*
233f661cstas * Copyright (c) 1999 - 2001 Kungliga Tekniska H��gskolan
34ecbd6dmarkm * (Royal Institute of Technology, Stockholm, Sweden).
44ecbd6dmarkm * All rights reserved.
533f661cstas *
64ecbd6dmarkm * Redistribution and use in source and binary forms, with or without
74ecbd6dmarkm * modification, are permitted provided that the following conditions
84ecbd6dmarkm * are met:
933f661cstas *
104ecbd6dmarkm * 1. Redistributions of source code must retain the above copyright
114ecbd6dmarkm *    notice, this list of conditions and the following disclaimer.
1233f661cstas *
134ecbd6dmarkm * 2. Redistributions in binary form must reproduce the above copyright
144ecbd6dmarkm *    notice, this list of conditions and the following disclaimer in the
154ecbd6dmarkm *    documentation and/or other materials provided with the distribution.
1633f661cstas *
174ecbd6dmarkm * 3. Neither the name of the Institute nor the names of its contributors
184ecbd6dmarkm *    may be used to endorse or promote products derived from this software
194ecbd6dmarkm *    without specific prior written permission.
2033f661cstas *
214ecbd6dmarkm * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
224ecbd6dmarkm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
234ecbd6dmarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
244ecbd6dmarkm * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
254ecbd6dmarkm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
264ecbd6dmarkm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
274ecbd6dmarkm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
284ecbd6dmarkm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
294ecbd6dmarkm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
304ecbd6dmarkm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
314ecbd6dmarkm * SUCH DAMAGE.
324ecbd6dmarkm */
334ecbd6dmarkm
344ecbd6dmarkm#include <config.h>
354ecbd6dmarkm
364ecbd6dmarkm#include <stdlib.h>
374ecbd6dmarkm#include <err.h>
384ecbd6dmarkm
3951b6601dfr#include "roken.h"
404ecbd6dmarkm
414ecbd6dmarkm/*
424ecbd6dmarkm * Like malloc but never fails.
434ecbd6dmarkm */
444ecbd6dmarkm
4533f661cstasROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
464ecbd6dmarkmemalloc (size_t sz)
474ecbd6dmarkm{
484ecbd6dmarkm    void *tmp = malloc (sz);
494ecbd6dmarkm
504ecbd6dmarkm    if (tmp == NULL && sz != 0)
5169a91benectar	errx (1, "malloc %lu failed", (unsigned long)sz);
524ecbd6dmarkm    return tmp;
534ecbd6dmarkm}
54