1 /* Test for memory leak with large width and precision.
2 Copyright (C) 1991-2018 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library 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 GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
22 #include <sys/resource.h>
33 ret
= asprintf (&result
, "%133000.133001x", 17);
36 printf ("error: asprintf: %m\n");
42 wchar_t *result
= calloc (ret
+ 1, sizeof (wchar_t));
45 printf ("error: calloc (%d, %zu): %m", ret
+ 1, sizeof (wchar_t));
49 ret
= swprintf (result
, ret
+ 1, L
"%133000.133001x", 17);
52 printf ("error: swprintf: %d (%m)\n", ret
);
58 /* Limit the size of the process, so that the second allocation will
62 if (getrlimit (RLIMIT_AS
, &limit
) != 0)
64 printf ("getrlimit (RLIMIT_AS) failed: %m\n");
67 long target
= 200 * 1024 * 1024;
68 if (limit
.rlim_cur
== RLIM_INFINITY
|| limit
.rlim_cur
> target
)
70 limit
.rlim_cur
= target
;
71 if (setrlimit (RLIMIT_AS
, &limit
) != 0)
73 printf ("setrlimit (RLIMIT_AS) failed: %m\n");
81 ret
= asprintf (&result
, "%133000.999999999x", 17);
84 printf ("error: asprintf: incorrect result %d\n", ret
);
92 printf ("error: calloc (%d, %zu): %m", ret
+ 1, sizeof (wchar_t));
96 ret
= swprintf (result
, 100, L
"%133000.999999999x", 17);
99 printf ("error: swprintf: incorrect result %d\n", ret
);
107 #define TEST_FUNCTION do_test ()
108 #include "../test-skeleton.c"