The _SC_PHYS_PAGES method of calculating RAM works on Linux.
authorSam Lantinga <slouken@libsdl.org>
Thu, 17 Oct 2013 11:32:14 -0700
changeset 78226bd98963606b
parent 7821 c47ae79f0de8
child 7823 4ab3a5ee041d
The _SC_PHYS_PAGES method of calculating RAM works on Linux.
src/cpuinfo/SDL_cpuinfo.c
     1.1 --- a/src/cpuinfo/SDL_cpuinfo.c	Thu Oct 17 11:32:56 2013 -0700
     1.2 +++ b/src/cpuinfo/SDL_cpuinfo.c	Thu Oct 17 11:32:14 2013 -0700
     1.3 @@ -637,25 +637,6 @@
     1.4              }
     1.5          }
     1.6  #endif
     1.7 -#if 0 //def __LINUX__
     1.8 -        FILE *fpMemInfo = fopen("/proc/meminfo", "r");
     1.9 -        if (fpMemInfo) {
    1.10 -            char line[1024];
    1.11 -            const char *search = "MemTotal:";
    1.12 -            const size_t searchlen = SDL_strlen(search);
    1.13 -            while (fgets(line, sizeof(line), fpMemInfo)) {
    1.14 -                if (SDL_strncasecmp(search, line, searchlen) == 0) {
    1.15 -                    char *val = line+searchlen;
    1.16 -                    while (SDL_isspace(*val)) {
    1.17 -                        ++val;
    1.18 -                    }
    1.19 -                    SDL_SystemRAM = SDL_atoi(val) / 1024; /* convert from kB to MB */
    1.20 -                    break;
    1.21 -                }
    1.22 -            }
    1.23 -            fclose(fpMemInfo);
    1.24 -        }
    1.25 -#endif
    1.26      }
    1.27      return SDL_SystemRAM;
    1.28  }