Hi Collin,

> I have attached a patch that works on FreeBSD.

Thanks! In my 32 GiB VM it reports 31.5 GB; good.

May I ask for a few cosmetic changes:

> +    if (sysctlbyname ("vm.stats.vm.v_free_count", &free_pages,
> +                      &len, NULL, 0) == 0 && len == sizeof free_pages

Indentation: Since the expression spans more than one line,
please put the '&& len == sizeof free_pages' part on a new line.

> +        && (len = sizeof inactive_pages,
> +            sysctlbyname ("vm.stats.vm.v_inactive_count", &inactive_pages,
> +                          &len, NULL, 0) == 0)
> +        && len == sizeof inactive_pages)

It would be more readable (IMO) if this part was a second 'if' statement,
nested in the first one.

> +      {
> +        /* Avoid integer overflow when multiplying the number of pages by the
> +           page size.  */
> +        unsigned long long int page_size = getpagesize ();

Here, why not use 'double page_size', like in the other clauses of the
same function? Then avoiding overflow is a no-brainer. The function's
return type is 'double' anyway.

Bruno




Reply via email to