Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 14b4adb

Browse files
committed
Add an optional interface to turn malloc debugging on and off.
1 parent e270b43 commit 14b4adb

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

Python/sysmodule.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,29 @@ sys_setprofile(self, args)
124124
return None;
125125
}
126126

127+
#ifdef USE_MALLOPT
128+
/* Link with -lmalloc (or -lmpc) on an SGI */
129+
#include <malloc.h>
130+
131+
static object *
132+
sys_mdebug(self, args)
133+
object *self;
134+
object *args;
135+
{
136+
int flag;
137+
if (!getargs(args, "i", &flag))
138+
return NULL;
139+
mallopt(M_DEBUG, flag);
140+
INCREF(None);
141+
return None;
142+
}
143+
#endif /* USE_MALLOPT */
144+
127145
static struct methodlist sys_methods[] = {
128146
{"exit", sys_exit},
147+
#ifdef USE_MALLOPT
148+
{"mdebug", sys_mdebug},
149+
#endif
129150
{"setprofile", sys_setprofile},
130151
{"settrace", sys_settrace},
131152
{NULL, NULL} /* sentinel */

0 commit comments

Comments
 (0)