2 * xfuncs.c - safe malloc funcions
6 * Copyright (c) 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
8 * See file CREDITS for list of people who contributed to this
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2
13 * as published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 void *xmalloc(size_t size
)
33 if (!(p
= malloc(size
)))
34 panic("ERROR: out of memory\n");
36 debug("xmalloc %p (size %d)\n", p
, size
);
40 EXPORT_SYMBOL(xmalloc
);
42 void *xrealloc(void *ptr
, size_t size
)
46 if (!(p
= realloc(ptr
, size
)))
47 panic("ERROR: out of memory\n");
49 debug("xrealloc %p -> %p (size %d)\n", ptr
, p
, size
);
53 EXPORT_SYMBOL(xrealloc
);
55 void *xzalloc(size_t size
)
57 void *ptr
= xmalloc(size
);
61 EXPORT_SYMBOL(xzalloc
);
63 char *xstrdup(const char *s
)
68 panic("ERROR: out of memory\n");
71 EXPORT_SYMBOL(xstrdup
);