Mercurial > hg > xemacs-beta
comparison src/alloc.c @ 3176:1c2a4e4e81d9
[xemacs-hg @ 2005-12-25 11:21:45 by aidan]
Revert the alloc warning bugfix
author | aidan |
---|---|
date | Sun, 25 Dec 2005 11:21:46 +0000 |
parents | db0631f96757 |
children | d674024a8674 |
comparison
equal
deleted
inserted
replaced
3175:f102dbecac7b | 3176:1c2a4e4e81d9 |
---|---|
229 xfree (tmp, void *); | 229 xfree (tmp, void *); |
230 } | 230 } |
231 } | 231 } |
232 #endif /* not MC_ALLOC */ | 232 #endif /* not MC_ALLOC */ |
233 | 233 |
234 /* malloc calls this if it finds we are near exhausting storage */ | |
235 void | |
236 malloc_warning (const char *str) | |
237 { | |
238 if (ignore_malloc_warnings) | |
239 return; | |
240 | |
241 warn_when_safe | |
242 (Qmemory, Qemergency, | |
243 "%s\n" | |
244 "Killing some buffers may delay running out of memory.\n" | |
245 "However, certainly by the time you receive the 95%% warning,\n" | |
246 "you should clean up, kill this Emacs, and start a new one.", | |
247 str); | |
248 } | |
249 | |
234 /* Called if malloc returns zero */ | 250 /* Called if malloc returns zero */ |
235 DOESNT_RETURN | 251 DOESNT_RETURN |
236 memory_full (void) | 252 memory_full (void) |
237 { | 253 { |
238 fprintf (stderr, "##### M E M O R Y F U L L #####\n"); | 254 fprintf (stderr, "##### M E M O R Y F U L L #####\n"); |
272 if ((char *) val < (char *) minimum_address_seen) | 288 if ((char *) val < (char *) minimum_address_seen) |
273 minimum_address_seen = (char *) val; | 289 minimum_address_seen = (char *) val; |
274 } | 290 } |
275 | 291 |
276 #ifdef ERROR_CHECK_MALLOC | 292 #ifdef ERROR_CHECK_MALLOC |
277 static int in_malloc, in_malloc_warning; | 293 static int in_malloc; |
278 extern int regex_malloc_disallowed; | 294 extern int regex_malloc_disallowed; |
279 | 295 |
280 #define MALLOC_BEGIN() \ | 296 #define MALLOC_BEGIN() \ |
281 do \ | 297 do \ |
282 { \ | 298 { \ |
283 assert (!in_malloc || in_malloc_warning); \ | 299 assert (!in_malloc); \ |
284 assert (!regex_malloc_disallowed); \ | 300 assert (!regex_malloc_disallowed); \ |
285 in_malloc = 1; \ | 301 in_malloc = 1; \ |
286 } \ | 302 } \ |
287 while (0) | 303 while (0) |
288 | |
289 #define MALLOC_WARNING_BEGIN() (++in_malloc_warning) | |
290 #define MALLOC_WARNING_END() (--in_malloc_warning) | |
291 | 304 |
292 #ifdef MC_ALLOC | 305 #ifdef MC_ALLOC |
293 #define FREE_OR_REALLOC_BEGIN(block) \ | 306 #define FREE_OR_REALLOC_BEGIN(block) \ |
294 do \ | 307 do \ |
295 { \ | 308 { \ |
326 while (0) | 339 while (0) |
327 | 340 |
328 #else /* ERROR_CHECK_MALLOC */ | 341 #else /* ERROR_CHECK_MALLOC */ |
329 | 342 |
330 #define MALLOC_BEGIN() | 343 #define MALLOC_BEGIN() |
331 #define MALLOC_WARNING_BEGIN() | |
332 #define MALLOC_WARNING_END() | |
333 #define FREE_OR_REALLOC_BEGIN(block) | 344 #define FREE_OR_REALLOC_BEGIN(block) |
334 #define MALLOC_END() | 345 #define MALLOC_END() |
335 | 346 |
336 #endif /* ERROR_CHECK_MALLOC */ | 347 #endif /* ERROR_CHECK_MALLOC */ |
337 | |
338 /* malloc calls this if it finds we are near exhausting storage */ | |
339 void | |
340 malloc_warning (const char *str) | |
341 { | |
342 if (ignore_malloc_warnings) | |
343 return; | |
344 | |
345 MALLOC_WARNING_BEGIN(); | |
346 | |
347 warn_when_safe | |
348 (Qmemory, Qemergency, | |
349 "%s\n" | |
350 "Killing some buffers may delay running out of memory.\n" | |
351 "However, certainly by the time you receive the 95%% warning,\n" | |
352 "you should clean up, kill this Emacs, and start a new one.\n" | |
353 "On Unix, look into your resource limits; ulimit -d, especially.", | |
354 str); | |
355 | |
356 MALLOC_WARNING_END(); | |
357 } | |
358 | 348 |
359 static void | 349 static void |
360 malloc_after (void *val, Bytecount size) | 350 malloc_after (void *val, Bytecount size) |
361 { | 351 { |
362 if (!val && size != 0) | 352 if (!val && size != 0) |