1 /* Test for memory leak with large width and precision.
2 Copyright (C) 1991-2016 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/>. */
21 #include <sys/resource.h>
32 ret
= asprintf (&result
, "%133000.133001x", 17);
35 printf ("error: asprintf: %m\n");
41 wchar_t *result
= calloc (ret
+ 1, sizeof (wchar_t));
44 printf ("error: calloc (%d, %zu): %m", ret
+ 1, sizeof (wchar_t));
48 ret
= swprintf (result
, ret
+ 1, L
"%133000.133001x", 17);
51 printf ("error: swprintf: %d (%m)\n", ret
);
57 /* Limit the size of the process, so that the second allocation will
61 if (getrlimit (RLIMIT_AS
, &limit
) != 0)
63 printf ("getrlimit (RLIMIT_AS) failed: %m\n");
66 long target
= 200 * 1024 * 1024;
67 if (limit
.rlim_cur
== RLIM_INFINITY
|| limit
.rlim_cur
> target
)
69 limit
.rlim_cur
= target
;
70 if (setrlimit (RLIMIT_AS
, &limit
) != 0)
72 printf ("setrlimit (RLIMIT_AS) failed: %m\n");
80 ret
= asprintf (&result
, "%133000.999999999x", 17);
83 printf ("error: asprintf: incorrect result %d\n", ret
);
91 printf ("error: calloc (%d, %zu): %m", ret
+ 1, sizeof (wchar_t));
95 ret
= swprintf (result
, 100, L
"%133000.999999999x", 17);
98 printf ("error: swprintf: incorrect result %d\n", ret
);
106 #define TEST_FUNCTION do_test ()
107 #include "../test-skeleton.c"