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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8944
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Safe automatic memory allocation with out of memory checking.
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2 Copyright (C) 2003, 2005, 2007 Free Software Foundation, Inc.
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 Written by Bruno Haible <bruno@clisp.org>, 2003.
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13 GNU General Public License for more details.
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18 #ifndef _XMALLOCA_H
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 #define _XMALLOCA_H
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 #include "malloca.h"
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 #ifdef __cplusplus
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 extern "C" {
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 #endif
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 /* xmalloca(N) is a checking safe variant of alloca(N). It allocates N bytes
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 of memory allocated on the stack, that must be freed using freesa() before
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 the function returns. Upon failure, it exits with an error message. */
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 #if HAVE_ALLOCA
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 # define xmalloca(N) \
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 ((N) < 4032 - sa_increment \
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 ? (void *) ((char *) alloca ((N) + sa_increment) + sa_increment) \
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 : xmmalloca (N))
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 extern void * xmmalloca (size_t n);
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 #else
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 # define xmalloca(N) \
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 xmalloc (N)
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 #endif
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 /* Maybe we should also define a variant
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 xnmalloca (size_t n, size_t s) - behaves like xmalloca (n * s)
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 If this would be useful in your application. please speak up. */
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 #ifdef __cplusplus
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 }
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 #endif
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52
b04902755c7f Move to here from xallocsa.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 #endif /* _XMALLOCA_H */