Check-in [eec9ca6159]
Overview
Comment:Updated to attempt to free allocated memory from statgrab
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: eec9ca615979d8e1dd1133a7f9a5df6215a95a5f
User & Date: rkeene on 2014-01-21 00:31:22
Other Links: manifest | tags
Context
2014-01-21
00:32
Freecolor 0.9.0 check-in: 9a61fdc3b3 user: rkeene tags: trunk, 0.9.0
00:31
Updated to attempt to free allocated memory from statgrab check-in: eec9ca6159 user: rkeene tags: trunk
00:25
Refactored code check-in: 99558b2093 user: rkeene tags: trunk
Changes

Modified aclocal.m4 from [fc41529d11] to [f9b658cac8].

40
41
42
43
44
45
46






47
48
49
50
51
52
53
54
55
56
57
  		  AC_CHECK_HEADER(statgrab.h, [
		    AC_DEFINE(HAVE_LIBSTATGRAB_H, [1], [Define to 1 if you have the <statgrab.h> header file.])
		    AC_DEFINE(HAVE_LIBSTATGRAB, [1], [Define to 1 if you have sg_get_mem_stats from -lstatgrab])
		    LIBS="$LIBS $LIBSTATGRABFLAGS -lstatgrab"
  		    AC_CHECK_LIB(statgrab, statgrab_drop_privileges, [
		      AC_DEFINE(HAVE_STATGRAB_DROP_PRIVILEGES, [1], [Define to 1 if you have statgrab_drop_privileges from -lstatgrab])
		    ])






		  ], [
		    CFLAGS="$OLDCFLAGS"
		    CPPFLAGS="$OLDCPPFLAGS"
		    AC_MSG_ERROR(Could not find statgrab.h)
		  ])
		], [
		  AC_MSG_ERROR(Could not find libstatgrab)
		], $LIBSTATGRABFLAGS)
  		;;
  esac
])







>
>
>
>
>
>











40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  		  AC_CHECK_HEADER(statgrab.h, [
		    AC_DEFINE(HAVE_LIBSTATGRAB_H, [1], [Define to 1 if you have the <statgrab.h> header file.])
		    AC_DEFINE(HAVE_LIBSTATGRAB, [1], [Define to 1 if you have sg_get_mem_stats from -lstatgrab])
		    LIBS="$LIBS $LIBSTATGRABFLAGS -lstatgrab"
  		    AC_CHECK_LIB(statgrab, statgrab_drop_privileges, [
		      AC_DEFINE(HAVE_STATGRAB_DROP_PRIVILEGES, [1], [Define to 1 if you have statgrab_drop_privileges from -lstatgrab])
		    ])
  		    AC_CHECK_LIB(statgrab, sg_free_mem_stats, [
		      AC_DEFINE(HAVE_SG_FREE_MEM_STATS, [1], [Define to 1 if you have sg_free_mem_stats from -lstatgrab])
		    ])
  		    AC_CHECK_LIB(statgrab, sg_free_swap_stats, [
		      AC_DEFINE(HAVE_SG_FREE_SWAP_STATS, [1], [Define to 1 if you have sg_free_swap_stats from -lstatgrab])
		    ])
		  ], [
		    CFLAGS="$OLDCFLAGS"
		    CPPFLAGS="$OLDCPPFLAGS"
		    AC_MSG_ERROR(Could not find statgrab.h)
		  ])
		], [
		  AC_MSG_ERROR(Could not find libstatgrab)
		], $LIBSTATGRABFLAGS)
  		;;
  esac
])

Modified config.h.in from [e74e26b184] to [c1a33a19d5].

1
2
3
4
5
6
7
8
9
10
11
12
13






14
15
16
17
18
19
20
/* config.h.in.  Generated from configure.in by autoheader.  */

/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H

/* Define to 1 if you have sg_get_mem_stats from -lstatgrab */
#undef HAVE_LIBSTATGRAB

/* Define to 1 if you have the <statgrab.h> header file. */
#undef HAVE_LIBSTATGRAB_H

/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H







/* Define to 1 if you have statgrab_drop_privileges from -lstatgrab */
#undef HAVE_STATGRAB_DROP_PRIVILEGES

/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H














>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* config.h.in.  Generated from configure.in by autoheader.  */

/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H

/* Define to 1 if you have sg_get_mem_stats from -lstatgrab */
#undef HAVE_LIBSTATGRAB

/* Define to 1 if you have the <statgrab.h> header file. */
#undef HAVE_LIBSTATGRAB_H

/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H

/* Define to 1 if you have sg_free_mem_stats from -lstatgrab */
#undef HAVE_SG_FREE_MEM_STATS

/* Define to 1 if you have sg_free_swap_stats from -lstatgrab */
#undef HAVE_SG_FREE_SWAP_STATS

/* Define to 1 if you have statgrab_drop_privileges from -lstatgrab */
#undef HAVE_STATGRAB_DROP_PRIVILEGES

/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H

Modified configure from [62674d3600] to [4328da1660].

3541
3542
3543
3544
3545
3546
3547
























































































3548
3549
3550
3551
3552
3553
3554
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_statgrab_statgrab_drop_privileges" >&5
$as_echo "$ac_cv_lib_statgrab_statgrab_drop_privileges" >&6; }
if test "x$ac_cv_lib_statgrab_statgrab_drop_privileges" = xyes; then :


$as_echo "#define HAVE_STATGRAB_DROP_PRIVILEGES 1" >>confdefs.h


























































































fi


else

		    CFLAGS="$OLDCFLAGS"







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_statgrab_statgrab_drop_privileges" >&5
$as_echo "$ac_cv_lib_statgrab_statgrab_drop_privileges" >&6; }
if test "x$ac_cv_lib_statgrab_statgrab_drop_privileges" = xyes; then :


$as_echo "#define HAVE_STATGRAB_DROP_PRIVILEGES 1" >>confdefs.h


fi

  		    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sg_free_mem_stats in -lstatgrab" >&5
$as_echo_n "checking for sg_free_mem_stats in -lstatgrab... " >&6; }
if ${ac_cv_lib_statgrab_sg_free_mem_stats+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lstatgrab  $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char sg_free_mem_stats ();
int
main ()
{
return sg_free_mem_stats ();
  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_lib_statgrab_sg_free_mem_stats=yes
else
  ac_cv_lib_statgrab_sg_free_mem_stats=no
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_statgrab_sg_free_mem_stats" >&5
$as_echo "$ac_cv_lib_statgrab_sg_free_mem_stats" >&6; }
if test "x$ac_cv_lib_statgrab_sg_free_mem_stats" = xyes; then :


$as_echo "#define HAVE_SG_FREE_MEM_STATS 1" >>confdefs.h


fi

  		    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sg_free_swap_stats in -lstatgrab" >&5
$as_echo_n "checking for sg_free_swap_stats in -lstatgrab... " >&6; }
if ${ac_cv_lib_statgrab_sg_free_swap_stats+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lstatgrab  $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char sg_free_swap_stats ();
int
main ()
{
return sg_free_swap_stats ();
  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_lib_statgrab_sg_free_swap_stats=yes
else
  ac_cv_lib_statgrab_sg_free_swap_stats=no
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_statgrab_sg_free_swap_stats" >&5
$as_echo "$ac_cv_lib_statgrab_sg_free_swap_stats" >&6; }
if test "x$ac_cv_lib_statgrab_sg_free_swap_stats" = xyes; then :


$as_echo "#define HAVE_SG_FREE_SWAP_STATS 1" >>confdefs.h


fi


else

		    CFLAGS="$OLDCFLAGS"

Modified freecolor.c from [23ac99bb04] to [51a20f4879].

185
186
187
188
189
190
191







192
193
194
195
196
197
198
	retval->totalram  = mem_stats->total;
	retval->freeram   = mem_stats->free;
	retval->cachedram = mem_stats->cache;
	retval->sharedram = 0;
	retval->bufferram = 0;
	retval->totalswap = swap_stats->total;
	retval->freeswap  = swap_stats->free;








	return(0);
}
#endif

int main(int argc, char **argv) {
	struct freecolor_meminfo sinfo;







>
>
>
>
>
>
>







185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
	retval->totalram  = mem_stats->total;
	retval->freeram   = mem_stats->free;
	retval->cachedram = mem_stats->cache;
	retval->sharedram = 0;
	retval->bufferram = 0;
	retval->totalswap = swap_stats->total;
	retval->freeswap  = swap_stats->free;

#ifdef HAVE_SG_FREE_MEM_STATS
	sg_free_mem_stats(mem_stats);
#endif
#ifdef HAVE_SG_FREE_SWAP_STATS
	sg_free_swap_stats(swap_stats);
#endif

	return(0);
}
#endif

int main(int argc, char **argv) {
	struct freecolor_meminfo sinfo;