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

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

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

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

     7      7   #undef HAVE_LIBSTATGRAB
     8      8   
     9      9   /* Define to 1 if you have the <statgrab.h> header file. */
    10     10   #undef HAVE_LIBSTATGRAB_H
    11     11   
    12     12   /* Define to 1 if you have the <memory.h> header file. */
    13     13   #undef HAVE_MEMORY_H
           14  +
           15  +/* Define to 1 if you have sg_free_mem_stats from -lstatgrab */
           16  +#undef HAVE_SG_FREE_MEM_STATS
           17  +
           18  +/* Define to 1 if you have sg_free_swap_stats from -lstatgrab */
           19  +#undef HAVE_SG_FREE_SWAP_STATS
    14     20   
    15     21   /* Define to 1 if you have statgrab_drop_privileges from -lstatgrab */
    16     22   #undef HAVE_STATGRAB_DROP_PRIVILEGES
    17     23   
    18     24   /* Define to 1 if you have the <stdint.h> header file. */
    19     25   #undef HAVE_STDINT_H
    20     26   

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

  3541   3541   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_statgrab_statgrab_drop_privileges" >&5
  3542   3542   $as_echo "$ac_cv_lib_statgrab_statgrab_drop_privileges" >&6; }
  3543   3543   if test "x$ac_cv_lib_statgrab_statgrab_drop_privileges" = xyes; then :
  3544   3544   
  3545   3545   
  3546   3546   $as_echo "#define HAVE_STATGRAB_DROP_PRIVILEGES 1" >>confdefs.h
  3547   3547   
         3548  +
         3549  +fi
         3550  +
         3551  +  		    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sg_free_mem_stats in -lstatgrab" >&5
         3552  +$as_echo_n "checking for sg_free_mem_stats in -lstatgrab... " >&6; }
         3553  +if ${ac_cv_lib_statgrab_sg_free_mem_stats+:} false; then :
         3554  +  $as_echo_n "(cached) " >&6
         3555  +else
         3556  +  ac_check_lib_save_LIBS=$LIBS
         3557  +LIBS="-lstatgrab  $LIBS"
         3558  +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
         3559  +/* end confdefs.h.  */
         3560  +
         3561  +/* Override any GCC internal prototype to avoid an error.
         3562  +   Use char because int might match the return type of a GCC
         3563  +   builtin and then its argument prototype would still apply.  */
         3564  +#ifdef __cplusplus
         3565  +extern "C"
         3566  +#endif
         3567  +char sg_free_mem_stats ();
         3568  +int
         3569  +main ()
         3570  +{
         3571  +return sg_free_mem_stats ();
         3572  +  ;
         3573  +  return 0;
         3574  +}
         3575  +_ACEOF
         3576  +if ac_fn_c_try_link "$LINENO"; then :
         3577  +  ac_cv_lib_statgrab_sg_free_mem_stats=yes
         3578  +else
         3579  +  ac_cv_lib_statgrab_sg_free_mem_stats=no
         3580  +fi
         3581  +rm -f core conftest.err conftest.$ac_objext \
         3582  +    conftest$ac_exeext conftest.$ac_ext
         3583  +LIBS=$ac_check_lib_save_LIBS
         3584  +fi
         3585  +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_statgrab_sg_free_mem_stats" >&5
         3586  +$as_echo "$ac_cv_lib_statgrab_sg_free_mem_stats" >&6; }
         3587  +if test "x$ac_cv_lib_statgrab_sg_free_mem_stats" = xyes; then :
         3588  +
         3589  +
         3590  +$as_echo "#define HAVE_SG_FREE_MEM_STATS 1" >>confdefs.h
         3591  +
         3592  +
         3593  +fi
         3594  +
         3595  +  		    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sg_free_swap_stats in -lstatgrab" >&5
         3596  +$as_echo_n "checking for sg_free_swap_stats in -lstatgrab... " >&6; }
         3597  +if ${ac_cv_lib_statgrab_sg_free_swap_stats+:} false; then :
         3598  +  $as_echo_n "(cached) " >&6
         3599  +else
         3600  +  ac_check_lib_save_LIBS=$LIBS
         3601  +LIBS="-lstatgrab  $LIBS"
         3602  +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
         3603  +/* end confdefs.h.  */
         3604  +
         3605  +/* Override any GCC internal prototype to avoid an error.
         3606  +   Use char because int might match the return type of a GCC
         3607  +   builtin and then its argument prototype would still apply.  */
         3608  +#ifdef __cplusplus
         3609  +extern "C"
         3610  +#endif
         3611  +char sg_free_swap_stats ();
         3612  +int
         3613  +main ()
         3614  +{
         3615  +return sg_free_swap_stats ();
         3616  +  ;
         3617  +  return 0;
         3618  +}
         3619  +_ACEOF
         3620  +if ac_fn_c_try_link "$LINENO"; then :
         3621  +  ac_cv_lib_statgrab_sg_free_swap_stats=yes
         3622  +else
         3623  +  ac_cv_lib_statgrab_sg_free_swap_stats=no
         3624  +fi
         3625  +rm -f core conftest.err conftest.$ac_objext \
         3626  +    conftest$ac_exeext conftest.$ac_ext
         3627  +LIBS=$ac_check_lib_save_LIBS
         3628  +fi
         3629  +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_statgrab_sg_free_swap_stats" >&5
         3630  +$as_echo "$ac_cv_lib_statgrab_sg_free_swap_stats" >&6; }
         3631  +if test "x$ac_cv_lib_statgrab_sg_free_swap_stats" = xyes; then :
         3632  +
         3633  +
         3634  +$as_echo "#define HAVE_SG_FREE_SWAP_STATS 1" >>confdefs.h
         3635  +
  3548   3636   
  3549   3637   fi
  3550   3638   
  3551   3639   
  3552   3640   else
  3553   3641   
  3554   3642   		    CFLAGS="$OLDCFLAGS"

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

   185    185   	retval->totalram  = mem_stats->total;
   186    186   	retval->freeram   = mem_stats->free;
   187    187   	retval->cachedram = mem_stats->cache;
   188    188   	retval->sharedram = 0;
   189    189   	retval->bufferram = 0;
   190    190   	retval->totalswap = swap_stats->total;
   191    191   	retval->freeswap  = swap_stats->free;
          192  +
          193  +#ifdef HAVE_SG_FREE_MEM_STATS
          194  +	sg_free_mem_stats(mem_stats);
          195  +#endif
          196  +#ifdef HAVE_SG_FREE_SWAP_STATS
          197  +	sg_free_swap_stats(swap_stats);
          198  +#endif
   192    199   
   193    200   	return(0);
   194    201   }
   195    202   #endif
   196    203   
   197    204   int main(int argc, char **argv) {
   198    205   	struct freecolor_meminfo sinfo;
................................................................................
   322    329   			}
   323    330   		}
   324    331   
   325    332   		if (doloop==0) {
   326    333   			break;
   327    334   		}
   328    335   
   329         -		usleep(doloop*1000000);
   330         -		printf("\033[%iA",linestoup);
          336  +		usleep(doloop * 1000000);
          337  +		printf("\033[%iA", linestoup);
   331    338   	}
   332    339   
   333    340   	return(0);
   334    341   }