diff options
author | Seonah Moon <seonah1.moon@samsung.com> | 2021-02-04 10:08:28 +0900 |
---|---|---|
committer | Seonah Moon <seonah1.moon@samsung.com> | 2021-02-04 10:08:57 +0900 |
commit | 99a33f08e5808e9b4ea40f9ba0d717196b2ef090 (patch) | |
tree | cc6d986a1f22e98bfcd987e83778d829f1dbecde /lib/gltests/test-alloca-opt.c | |
parent | 40d523a658c1a2e2311f0d588a96cbfb7eded09f (diff) | |
download | libidn-99a33f08e5808e9b4ea40f9ba0d717196b2ef090.tar.gz libidn-99a33f08e5808e9b4ea40f9ba0d717196b2ef090.tar.bz2 libidn-99a33f08e5808e9b4ea40f9ba0d717196b2ef090.zip |
Imported Upstream version 1.23upstream/1.23upstream
Change-Id: Icfaf3a8b6a8c778e14a771acd595696cdbded864
Diffstat (limited to 'lib/gltests/test-alloca-opt.c')
-rw-r--r-- | lib/gltests/test-alloca-opt.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/lib/gltests/test-alloca-opt.c b/lib/gltests/test-alloca-opt.c new file mode 100644 index 0000000..5aa1645 --- /dev/null +++ b/lib/gltests/test-alloca-opt.c @@ -0,0 +1,62 @@ +/* Test of optional automatic memory allocation. + Copyright (C) 2005, 2007, 2009-2011 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include <alloca.h> + +#if HAVE_ALLOCA + +static void +do_allocation (int n) +{ + void *ptr = alloca (n); + (void) ptr; +} + +void (*func) (int) = do_allocation; + +#endif + +int +main () +{ +#if HAVE_ALLOCA + int i; + + /* Repeat a lot of times, to make sure there's no memory leak. */ + for (i = 0; i < 100000; i++) + { + /* Try various values. + n = 0 gave a crash on Alpha with gcc-2.5.8. + Some versions of MacOS X have a stack size limit of 512 KB. */ + func (34); + func (134); + func (399); + func (510823); + func (129321); + func (0); + func (4070); + func (4095); + func (1); + func (16582); + } +#endif + + return 0; +} |