wok rev 4345

syslinux: ifmem.c32 accepts unit K, M, G
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Oct 02 11:37:50 2009 +0200 (2009-10-02)
parents a677ef914cf6
children cb3111ed47e8
files syslinux/stuff/extra/ifmem.c
line diff
     1.1 --- a/syslinux/stuff/extra/ifmem.c	Thu Oct 01 22:03:57 2009 +0200
     1.2 +++ b/syslinux/stuff/extra/ifmem.c	Fri Oct 02 11:37:50 2009 +0200
     1.3 @@ -108,8 +108,17 @@
     1.4    ram_size = memory_size();
     1.5    printf("Total memory found %luK.\n",ram_size);
     1.6    for (i = 1; i + 2 < argc; ) { 
     1.7 +    char *p = s;
     1.8 +    unsigned long scale = 1;
     1.9 +    
    1.10 +    if (*p) while (p[1]) p++;
    1.11 +    switch (*p | 0x20) {
    1.12 +    case 'g': scale = 1024*1024; *p = 0; break;
    1.13 +    case 'm': scale = 1024;
    1.14 +    case 'k': *p = 0; break;
    1.15 +    }
    1.16      j = i++; // size
    1.17 -    if (ram_size >= strtoul(s, NULL, 0)) break;
    1.18 +    if (ram_size >= scale * strtoul(s, NULL, 0)) break;
    1.19      s = argv[++i];
    1.20    }
    1.21  
    1.22 @@ -119,7 +128,7 @@
    1.23  	char c = *argv[i];
    1.24  	if (c >= '0' && c <= '9') j = i;
    1.25  	if (i - j > 2 && i < argc) {
    1.26 -#define SZ 512
    1.27 +#define SZ 4096
    1.28  		static char cmdline[SZ];
    1.29  		char *p = cmdline, *q = s;
    1.30  		int j;