Mercurial > hg > xemacs-beta
comparison src/vm-limit.c @ 410:de805c49cfc1 r21-2-35
Import from CVS: tag r21-2-35
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:19:21 +0200 |
parents | a86b2b5e0111 |
children | 697ef44129c6 |
comparison
equal
deleted
inserted
replaced
409:301b9ebbdf3b | 410:de805c49cfc1 |
---|---|
55 extern POINTER (*__morecore) (ptrdiff_t size); | 55 extern POINTER (*__morecore) (ptrdiff_t size); |
56 | 56 |
57 POINTER cp; | 57 POINTER cp; |
58 unsigned long five_percent; | 58 unsigned long five_percent; |
59 unsigned long data_size; | 59 unsigned long data_size; |
60 void (*save_warn_fun) (const char *); | |
60 | 61 |
61 if (lim_data == 0) | 62 if (lim_data == 0) |
62 get_lim_data (); | 63 get_lim_data (); |
63 five_percent = lim_data / 20; | 64 five_percent = lim_data / 20; |
64 | 65 |
65 /* Find current end of memory and issue warning if getting near max */ | 66 /* Find current end of memory and issue warning if getting near max */ |
66 cp = (char *) (*__morecore) (0); | 67 cp = (char *) (*__morecore) (0); |
67 data_size = (char *) cp - (char *) data_space_start; | 68 data_size = (char *) cp - (char *) data_space_start; |
68 | 69 |
69 if (warn_function) | 70 if (warn_function) |
70 switch (warnlevel) | 71 { |
71 { | 72 /* temporarily reset the warn_function to 0 or we will get infinite |
72 case 0: | 73 looping. */ |
73 if (data_size > five_percent * 15) | 74 save_warn_fun = warn_function; |
74 { | 75 warn_function = 0; |
75 warnlevel++; | 76 switch (warnlevel) |
76 (*warn_function) ("Warning: past 75% of memory limit"); | 77 { |
77 } | 78 case 0: |
78 break; | 79 if (data_size > five_percent * 15) |
80 { | |
81 warnlevel++; | |
82 (*warn_function) ("Warning: past 75% of memory limit"); | |
83 } | |
84 break; | |
79 | 85 |
80 case 1: | 86 case 1: |
81 if (data_size > five_percent * 17) | 87 if (data_size > five_percent * 17) |
82 { | 88 { |
83 warnlevel++; | 89 warnlevel++; |
84 (*warn_function) ("Warning: past 85% of memory limit"); | 90 (*warn_function) ("Warning: past 85% of memory limit"); |
85 } | 91 } |
86 break; | 92 break; |
87 | 93 |
88 case 2: | 94 case 2: |
89 if (data_size > five_percent * 19) | 95 if (data_size > five_percent * 19) |
90 { | 96 { |
91 warnlevel++; | 97 warnlevel++; |
92 (*warn_function) ("Warning: past 95% of memory limit"); | 98 (*warn_function) ("Warning: past 95% of memory limit"); |
93 } | 99 } |
94 break; | 100 break; |
95 | 101 |
96 default: | 102 default: |
97 (*warn_function) ("Warning: past acceptable memory limits"); | 103 (*warn_function) ("Warning: past acceptable memory limits"); |
98 break; | 104 break; |
99 } | 105 } |
106 warn_function = save_warn_fun; | |
107 } | |
100 | 108 |
101 /* If we go down below 70% full, issue another 75% warning | 109 /* If we go down below 70% full, issue another 75% warning |
102 when we go up again. */ | 110 when we go up again. */ |
103 if (data_size < five_percent * 14) | 111 if (data_size < five_percent * 14) |
104 warnlevel = 0; | 112 warnlevel = 0; |