Mercurial > hg > octave-nkf > gnulib-hg
annotate lib/xmalloca.h @ 9309:bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 07 Oct 2007 19:14:58 +0200 |
parents | b04902755c7f |
children | 18c67ec54b59 |
rev | line source |
---|---|
8944 | 1 /* Safe automatic memory allocation with out of memory checking. |
2 Copyright (C) 2003, 2005, 2007 Free Software Foundation, Inc. | |
3 Written by Bruno Haible <bruno@clisp.org>, 2003. | |
4 | |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8944
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify |
8944 | 6 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8944
diff
changeset
|
7 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8944
diff
changeset
|
8 (at your option) any later version. |
8944 | 9 |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8944
diff
changeset
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
8944 | 17 |
18 #ifndef _XMALLOCA_H | |
19 #define _XMALLOCA_H | |
20 | |
21 #include "malloca.h" | |
22 | |
23 | |
24 #ifdef __cplusplus | |
25 extern "C" { | |
26 #endif | |
27 | |
28 | |
29 /* xmalloca(N) is a checking safe variant of alloca(N). It allocates N bytes | |
30 of memory allocated on the stack, that must be freed using freesa() before | |
31 the function returns. Upon failure, it exits with an error message. */ | |
32 #if HAVE_ALLOCA | |
33 # define xmalloca(N) \ | |
34 ((N) < 4032 - sa_increment \ | |
35 ? (void *) ((char *) alloca ((N) + sa_increment) + sa_increment) \ | |
36 : xmmalloca (N)) | |
37 extern void * xmmalloca (size_t n); | |
38 #else | |
39 # define xmalloca(N) \ | |
40 xmalloc (N) | |
41 #endif | |
42 | |
43 /* Maybe we should also define a variant | |
44 xnmalloca (size_t n, size_t s) - behaves like xmalloca (n * s) | |
45 If this would be useful in your application. please speak up. */ | |
46 | |
47 | |
48 #ifdef __cplusplus | |
49 } | |
50 #endif | |
51 | |
52 | |
53 #endif /* _XMALLOCA_H */ |