xref: /netbsd-src/sys/arch/atari/stand/tostools/libtos/xalloc.c (revision 454af1c0e885cbba6b59706391f770d646303f8c)
1*454af1c0Sdsl /*	$NetBSD: xalloc.c,v 1.3 2009/03/14 15:36:04 dsl Exp $	*/
2b24ea33cSleo 
3b24ea33cSleo /*
4b24ea33cSleo  * Copyright (c) 1995 Waldi Ravens.
5b24ea33cSleo  * All rights reserved.
6b24ea33cSleo  *
7b24ea33cSleo  * Redistribution and use in source and binary forms, with or without
8b24ea33cSleo  * modification, are permitted provided that the following conditions
9b24ea33cSleo  * are met:
10b24ea33cSleo  * 1. Redistributions of source code must retain the above copyright
11b24ea33cSleo  *    notice, this list of conditions and the following disclaimer.
12b24ea33cSleo  * 2. Redistributions in binary form must reproduce the above copyright
13b24ea33cSleo  *    notice, this list of conditions and the following disclaimer in the
14b24ea33cSleo  *    documentation and/or other materials provided with the distribution.
15b24ea33cSleo  * 3. All advertising materials mentioning features or use of this software
16b24ea33cSleo  *    must display the following acknowledgement:
17b24ea33cSleo  *        This product includes software developed by Waldi Ravens.
18b24ea33cSleo  * 4. The name of the author may not be used to endorse or promote products
19b24ea33cSleo  *    derived from this software without specific prior written permission.
20b24ea33cSleo  *
21b24ea33cSleo  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22b24ea33cSleo  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23b24ea33cSleo  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24b24ea33cSleo  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25b24ea33cSleo  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26b24ea33cSleo  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27b24ea33cSleo  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28b24ea33cSleo  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29b24ea33cSleo  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30b24ea33cSleo  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31b24ea33cSleo  */
32b24ea33cSleo 
33b24ea33cSleo #include <stdlib.h>
34b24ea33cSleo #include "libtos.h"
35b24ea33cSleo 
36b24ea33cSleo void *
xmalloc(size_t size)37*454af1c0Sdsl xmalloc(size_t size)
38b24ea33cSleo {
39b24ea33cSleo 	void *	p = malloc(size);
40b24ea33cSleo 
41b24ea33cSleo 	if (p || !size)
42b24ea33cSleo 		return(p);
43b24ea33cSleo 	fatal(-1, "Virtual memory exhausted");
44fa1cc128Sleo 	return NULL; /* Never gets here...*/
45b24ea33cSleo }
46b24ea33cSleo 
47b24ea33cSleo void *
xrealloc(void * ptr,size_t size)48*454af1c0Sdsl xrealloc(void *ptr, size_t size)
49b24ea33cSleo {
50b24ea33cSleo 	void *	p = realloc(ptr, size);
51b24ea33cSleo 
52b24ea33cSleo 	if (p || !size)
53b24ea33cSleo 		return(p);
54b24ea33cSleo 	fatal(-1, "Virtual memory exhausted");
55fa1cc128Sleo 	return NULL; /* Never gets here...*/
56b24ea33cSleo }
57