update dev300-m58
[ooovba.git] / dmake / dbug / malloc / m_init.c
bloba30326de14f20fb3759b975c20fbe7c72e25e7ac
1 /*
2 * (c) Copyright 1990 Conor P. Cahill (uunet!virtech!cpcahil).
3 * You may copy, distribute, and use this software as long as this
4 * copyright statement is not removed.
5 */
6 #include <stdio.h>
7 #include "malloc.h"
9 /*
10 * Function: malloc_init()
12 * Purpose: to initialize the pointers and variables use by the
13 * malloc() debugging library
15 * Arguments: none
17 * Returns: nothing of any value
19 * Narrative: Just initialize all the needed variables. Use mallopt
20 * to set options taken from the environment.
23 #ifndef lint
24 static
25 char rcs_hdr[] = "$Id: m_init.c,v 1.2 2006-07-25 10:08:07 rt Exp $";
26 #endif
28 void
29 malloc_init()
31 char * cptr;
32 char * getenv();
33 union malloptarg m;
34 extern char * malloc_data_end;
35 extern char * malloc_data_start;
36 extern struct mlist * malloc_end;
37 extern struct mlist malloc_start;
38 char * sbrk();
41 * If already initialized...
43 if( malloc_data_start != (char *) 0)
45 return;
49 malloc_data_start = sbrk(0);
50 malloc_data_end = malloc_data_start;
51 malloc_start.s.size = 0;
52 malloc_end = &malloc_start;
54 if( (cptr=getenv("MALLOC_WARN")) != NULL )
56 m.i = atoi(cptr);
57 (void) mallopt(MALLOC_WARN,m);
60 if( (cptr=getenv("MALLOC_FATAL")) != NULL)
62 m.i = atoi(cptr);
63 (void) mallopt(MALLOC_FATAL,m);
66 if( (cptr=getenv("MALLOC_CKCHAIN")) != NULL)
68 m.i = atoi(cptr);
69 (void) mallopt(MALLOC_CKCHAIN,m);
72 if( (cptr=getenv("MALLOC_ERRFILE")) != NULL)
74 m.str = cptr;
75 (void) mallopt(MALLOC_ERRFILE,m);