diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/edje/src/bin/epp/cppalloc.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/libraries/edje/src/bin/epp/cppalloc.c b/libraries/edje/src/bin/epp/cppalloc.c new file mode 100644 index 0000000..4ce0dd0 --- /dev/null +++ b/libraries/edje/src/bin/epp/cppalloc.c | |||
@@ -0,0 +1,70 @@ | |||
1 | /* Part of CPP library. (memory allocation - xmalloc etc) | ||
2 | * Copyright (C) 1986, 87, 89, 92, 93, 94, 1995 Free Software Foundation, Inc. | ||
3 | * Written by Per Bothner, 1994. | ||
4 | * Based on CCCP program by by Paul Rubin, June 1986 | ||
5 | * Adapted to ANSI C, Richard Stallman, Jan 1987 | ||
6 | * Copyright (C) 2003-2011 Kim Woelders | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2, or (at your option) any | ||
11 | * later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | ||
21 | * | ||
22 | * In other words, you are welcome to use, share and improve this program. | ||
23 | * You are forbidden to forbid anyone else to use, share and improve | ||
24 | * what you give them. Help stamp out software-hoarding! */ | ||
25 | |||
26 | #ifdef HAVE_CONFIG_H | ||
27 | # include <config.h> | ||
28 | #endif | ||
29 | |||
30 | #include <stdlib.h> | ||
31 | |||
32 | #include "cpplib.h" | ||
33 | |||
34 | static void | ||
35 | memory_full(void) | ||
36 | { | ||
37 | cpp_fatal("Memory exhausted."); | ||
38 | } | ||
39 | |||
40 | void * | ||
41 | xmalloc(unsigned size) | ||
42 | { | ||
43 | char *ptr = (char *)malloc(size); | ||
44 | |||
45 | if (ptr) | ||
46 | return (ptr); | ||
47 | memory_full(); | ||
48 | /*NOTREACHED */ | ||
49 | return 0; | ||
50 | } | ||
51 | |||
52 | void * | ||
53 | xrealloc(void *old, unsigned size) | ||
54 | { | ||
55 | char *ptr = (char *)realloc(old, size); | ||
56 | |||
57 | if (!ptr) | ||
58 | memory_full(); | ||
59 | return ptr; | ||
60 | } | ||
61 | |||
62 | void * | ||
63 | xcalloc(unsigned number, unsigned size) | ||
64 | { | ||
65 | char *ptr = (char *)calloc(number, size); | ||
66 | |||
67 | if (!ptr) | ||
68 | memory_full(); | ||
69 | return ptr; | ||
70 | } | ||