annotate doc/alloca-opt.texi @ 18025:5201cc72e203

savedir: avoid undefined behavior in qsort call GCC 5.1.1 -fsanitize=undefined with glibc 2.21 is returning: "runtime error: null pointer passed as argument 1, which is declared to never be null" * lib/savedir.c (streamsavedir): Avoid the call with no entries.
author Pádraig Brady <P@draigBrady.com>
date Wed, 24 Jun 2015 19:08:08 +0100
parents 69801cc56551
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5535
5a898d7a80a6 Documentation of 'alloca' and 'alloca-opt' modules.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 @c Documentation of gnulib module 'alloca-opt'.
5a898d7a80a6 Documentation of 'alloca' and 'alloca-opt' modules.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2
17848
ab58d4870664 version-etc: new year
Paul Eggert <eggert@cs.ucla.edu>
parents: 17587
diff changeset
3 @c Copyright (C) 2004, 2007, 2009-2015 Free Software Foundation, Inc.
7139
adb21c293305 Add copyright notices to long-enough files that lack them, since
Paul Eggert <eggert@cs.ucla.edu>
parents: 5535
diff changeset
4
adb21c293305 Add copyright notices to long-enough files that lack them, since
Paul Eggert <eggert@cs.ucla.edu>
parents: 5535
diff changeset
5 @c Permission is granted to copy, distribute and/or modify this document
10762
d67664a4e01c Change license to GFDLv1.3+.
Simon Josefsson <simon@josefsson.org>
parents: 9550
diff changeset
6 @c under the terms of the GNU Free Documentation License, Version 1.3 or
7139
adb21c293305 Add copyright notices to long-enough files that lack them, since
Paul Eggert <eggert@cs.ucla.edu>
parents: 5535
diff changeset
7 @c any later version published by the Free Software Foundation; with no
17967
69801cc56551 doc: update FDL template to match FDL examples.
Simon Josefsson <simon@josefsson.org>
parents: 17848
diff changeset
8 @c Invariant Sections, no Front-Cover Texts, and no Back-Cover
7139
adb21c293305 Add copyright notices to long-enough files that lack them, since
Paul Eggert <eggert@cs.ucla.edu>
parents: 5535
diff changeset
9 @c Texts. A copy of the license is included in the ``GNU Free
adb21c293305 Add copyright notices to long-enough files that lack them, since
Paul Eggert <eggert@cs.ucla.edu>
parents: 5535
diff changeset
10 @c Documentation License'' file as part of this distribution.
adb21c293305 Add copyright notices to long-enough files that lack them, since
Paul Eggert <eggert@cs.ucla.edu>
parents: 5535
diff changeset
11
9550
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
12 The alloca-opt module provides for a function @code{alloca} which allocates
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
13 memory on the stack, where the system allows it. A memory block allocated with
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
14 @code{alloca} exists only until the function that calls @code{alloca} returns
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
15 or exits abruptly.
5535
5a898d7a80a6 Documentation of 'alloca' and 'alloca-opt' modules.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
5a898d7a80a6 Documentation of 'alloca' and 'alloca-opt' modules.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 There are a few systems where this is not possible: HP-UX systems, and some
9550
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
18 other platforms when the C++ compiler is used. On these platforms the
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
19 alloca-opt module provides no replacement, just a preprocessor macro
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
20 HAVE_ALLOCA.
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
21
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
22 The user can @code{#include <alloca.h>} on all platforms, and use
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
23 @code{alloca} on those platforms where the preprocessor macro HAVE_ALLOCA
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
24 evaluates to true. If HAVE_ALLOCA is false, the code should use a heap-based
17223
4e33322b32f8 Hyphen and dash fixes.
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
25 memory allocation based on @code{malloc} or (in C++) @code{new}. Note that
9550
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
26 the @code{#include <alloca.h>} must be the first one after the
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
27 autoconf-generated @file{config.h}, for AIX 3 compatibility. Thanks to IBM for
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
28 this nice restriction!
5535
5a898d7a80a6 Documentation of 'alloca' and 'alloca-opt' modules.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29
9550
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
30 Note that GCC 3.1 and 3.2 can @emph{inline} functions that call @code{alloca}.
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
31 When this happens, the memory blocks allocated with @code{alloca} will not be
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
32 freed until @emph{the end of the calling function}. If this calling function
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
33 runs a loop calling the function that uses @code{alloca}, the program easily
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
34 gets a stack overflow and crashes. To protect against this compiler behaviour,
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
35 you can mark the function that uses @code{alloca} with the following attribute:
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
36
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
37 @smallexample
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
38 #ifdef __GNUC__
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
39 __attribute__ ((__noinline__))
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
40 #endif
6bc27027a2d6 Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
41 @end smallexample