File: botch.c

package info (click to toggle)
zmailer 2.99.51.52pre3-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 16,596 kB
  • ctags: 7,422
  • sloc: ansic: 90,470; sh: 3,608; makefile: 2,784; perl: 1,585; python: 115; awk: 22
file content (51 lines) | stat: -rw-r--r-- 1,300 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "defs.h"
#include "globals.h"

int
__nothing()
{
	return 0;
}

/*
 * Simple botch routine - writes directly to stderr.  CAREFUL -- do not use
 * printf because of the vile hack we use to redefine fputs with write for
 * normal systems (i.e not super-pure ANSI)!
 */
int
__m_botch(s1, s2, p, is_end_ptr, filename, linenumber)
const char *s1, *s2;
univptr_t p;
const char *filename;
int linenumber, is_end_ptr;
{
	static char linebuf[32];	/* Enough for a BIG linenumber! */
	static int notagain = 0;

	if (notagain == 0) {
		/* Try to flush the trace file and unbuffer stderr */
		(void) fflush(_malloc_statsfile);
		(void) setvbuf(stderr, (char *) 0, _IONBF, 0);
		(void) sprintf(linebuf, "%d: ", linenumber);
		(void) fputs("memory corruption found, file ",
			     stderr);
		(void) fputs(filename, stderr);
		(void) fputs(", line ", stderr);
		(void) fputs(linebuf, stderr);
		(void) fputs(s1, stderr);
		if (s2 && *s2) {
			(void) fputs(" ", stderr);
			(void) fputs(s2, stderr);
		}
		(void) fputs("\n", stderr);
		(void) __m_prblock(p, is_end_ptr, stderr);
		/*
		 * In case stderr is buffered and was written to before we
		 * tried to unbuffer it
		 */
		(void) fflush(stderr);
		notagain++;	/* just in case abort() tries to cleanup */
		abort();
	}
	return 0;	/* SHOULDNTHAPPEN */
}