The R Project SVN R

Rev

Rev 24283 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 24283 Rev 27310
Line 24... Line 24...
24
   WITHOUT ANY WARRANTY.
24
   WITHOUT ANY WARRANTY.
25
 
25
 
26
   See the file COPYLIB.TXT for details.
26
   See the file COPYLIB.TXT for details.
27
*/
27
*/
28
 
28
 
29
#define NONAMELESSUNION
-
 
30
#include "internal.h"
29
#include "internal.h"
31
 
30
 
32
extern void startgraphapp(HINSTANCE Instance, HINSTANCE PrevInstance, int CmdShow);
31
extern void startgraphapp(HINSTANCE Instance, HINSTANCE PrevInstance, int CmdShow);
33
 
32
 
34
 
-
 
35
__declspec(dllimport) extern unsigned int R_reserved_size;
-
 
36
#include <limits.h>
-
 
37
 
-
 
38
static void check_max_mem(int argc, char **argv)
-
 
39
{
-
 
40
    int ac = argc;
-
 
41
    char *p = NULL, **av = argv;
-
 
42
    long v;
-
 
43
 
-
 
44
    while (--ac) {
-
 
45
	++av;
-
 
46
	if(strncmp(*av, "--max-mem-size", 14) == 0) {
-
 
47
	    if(strlen(*av) < 16) {
-
 
48
		ac--; av++; p = *av;
-
 
49
	    } else p = &(*av)[15];
-
 
50
	    v = strtol(p, &p, 10);
-
 
51
	    if(p[0] == 'M') {
-
 
52
		if((1024*1024 * (double)v) > LONG_MAX) return;
-
 
53
		v = 1024*1024*v;
-
 
54
	    } else if(p[0] == 'K') {
-
 
55
		if((1024 * (double)v) > LONG_MAX) return;
-
 
56
		v = 1024*v;
-
 
57
	    } else if(p[0] == 'k') {
-
 
58
		if((1000 * (double)v) > LONG_MAX) return;
-
 
59
		v = 1000*v;
-
 
60
	    }
-
 
61
#ifdef LEA_MALLOC
-
 
62
	    if (v > R_reserved_size) R_reserved_size = v;
-
 
63
#endif
-
 
64
	    return;
-
 
65
	}
-
 
66
    }
-
 
67
}
-
 
68
 
-
 
69
/*
33
/*
70
 *  If PASS_ARGS is zero, the main function will be passed zero
34
 *  If PASS_ARGS is zero, the main function will be passed zero
71
 *  and NULL instead of argc and argv.
35
 *  and NULL instead of argc and argv.
72
 *  If it is one, the argc and argv parameters will be passed.
36
 *  If it is one, the argc and argv parameters will be passed.
73
 *  If it is two, the environ parameter will also be passed.
37
 *  If it is two, the environ parameter will also be passed.
Line 90... Line 54...
90
	extern void AppMain(int argc, char **argv);
54
	extern void AppMain(int argc, char **argv);
91
#else /* else pass zero and NULL to main */
55
#else /* else pass zero and NULL to main */
92
	extern void AppMain(int argc, char **argv);
56
	extern void AppMain(int argc, char **argv);
93
#endif /* end arg declarations */
57
#endif /* end arg declarations */
94
 
58
 
95
	/* do this here, before ANY used of malloc + friends */
-
 
96
	check_max_mem(_argc, _argv);
-
 
97
        startgraphapp(Instance, PrevInstance, CmdShow);
59
        startgraphapp(Instance, PrevInstance, CmdShow);
98
	/*
60
	/*
99
	 *  Call the main function now.
61
	 *  Call the main function now.
100
	*/
62
	*/
101
#if (PASS_ARGS > 1)		/* pass argc, argv, environ */
63
#if (PASS_ARGS > 1)		/* pass argc, argv, environ */