FreeBASIC  0.91.0
sys_fmem.c
Go to the documentation of this file.
1 /* fre() function */
2 
3 #include "../fb.h"
4 #include <sys/sysctl.h>
5 #include <sys/vmmeter.h>
6 #include <vm/vm_param.h>
7 
8 FBCALL size_t fb_GetMemAvail( int mode )
9 {
10  int mib[2] = { CTL_VM, VM_METER };
11  struct vmtotal vmt;
12  size_t size = sizeof(struct vmtotal);
13 
14  if( sysctl( mib, 2, &vmt, &size, NULL, 0 ) )
15  return 0;
16 
17  return vmt.t_free * sysconf( _SC_PAGE_SIZE );
18 }