mirror of
git://git.sv.gnu.org/autoconf
synced 2025-01-30 11:01:45 +08:00
Work around memory-leak false alarms
Problem reported by Raphael Isemann in: https://lists.gnu.org/r/autoconf-patches/2022-03/msg00007.html * lib/autoconf/c.m4 (_AC_C_C99_TEST_MAIN, AC_C_FLEXIBLE_ARRAY_MEMBER): * tests/data/gnulib_std_gnu11_2020_08_17.m4 (_AC_C_C99_TEST_HEADER): Free storage allocated via malloc, to pacify overly-picky implementations that issue false alarms about memory leaks.
This commit is contained in:
parent
c8d6d6eb8b
commit
ce3d5ff4f2
@ -1330,6 +1330,8 @@ ac_c_conftest_c99_main='
|
||||
ia->datasize = 10;
|
||||
for (int i = 0; i < ia->datasize; ++i)
|
||||
ia->data[i] = i * 1.234;
|
||||
// Work around memory leak warnings.
|
||||
free (ia);
|
||||
|
||||
// Check named initializers.
|
||||
struct named_init ni = {
|
||||
@ -2170,7 +2172,9 @@ AC_DEFUN([AC_C_FLEXIBLE_ARRAY_MEMBER],
|
||||
struct s *p = (struct s *) malloc (offsetof (struct s, d)
|
||||
+ m * sizeof (double));
|
||||
p->d[0] = 0.0;
|
||||
return p->d != (double *) NULL;]])],
|
||||
m = p->d != (double *) NULL;
|
||||
free (p);
|
||||
return m;]])],
|
||||
[ac_cv_c_flexmember=yes],
|
||||
[ac_cv_c_flexmember=no])])
|
||||
if test $ac_cv_c_flexmember = yes; then
|
||||
|
@ -319,6 +319,8 @@ AC_DEFUN([_AC_C_C99_TEST_BODY],
|
||||
ia->datasize = 10;
|
||||
for (int i = 0; i < ia->datasize; ++i)
|
||||
ia->data[i] = i * 1.234;
|
||||
// Work around memory leak warnings.
|
||||
free (ia);
|
||||
|
||||
// Check named initializers.
|
||||
struct named_init ni = {
|
||||
|
Loading…
Reference in New Issue
Block a user