⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mallopt.c

📁 对内存的分配、释放和使用进行检查
💻 C
字号:
/* * (c) Copyright 1990 Conor P. Cahill (uunet!virtech!cpcahil).   * You may copy, distribute, and use this software as long as this * copyright statement is not removed. */#include <stdio.h>#include <fcntl.h>#include "malloc.h"/* * Function:	mallopt() * * Purpose:	to set options for the malloc debugging library * * Arguments:	none * * Returns:	nothing of any value * * Narrative:	 * */#ifndef lintstaticchar rcs_hdr[] = "$Id: mallopt.c,v 1.4 90/05/11 00:13:10 cpcahil Exp $";#endifunion val{	int	  i;	char	* str;};intmallopt(cmd,value)	int			  cmd;	union val		  value;{	int			  i;	extern int		  malloc_checking;	extern char		* malloc_data_start;	extern int		  malloc_errfd;	extern int		  malloc_fatal_level;	void			  malloc_init();	extern int		  malloc_warn_level;	register char		* s;	/* 	 * If not initialized...	 */	if( malloc_data_start == (char *) 0)	{		malloc_init();	}	switch(cmd)	{		case MALLOC_WARN:			malloc_warn_level = value.i;			break;		case MALLOC_FATAL:			malloc_fatal_level = value.i;			break;		case MALLOC_CKCHAIN:			malloc_checking = value.i;			break;		case MALLOC_ERRFILE:						i = open(value.str,O_CREAT|O_APPEND|O_WRONLY,0666);			if( i == -1 )			{				(void) write(2,					  "Unable to open malloc error file: ",					  (unsigned) 34);				for(s=value.str; *s; s++)				{					/* do nothing */;				}				(void) write(2,value.str,					     (unsigned)(s-value.str));				(void) write(2,"\n",(unsigned)1);			}			else			{				if( malloc_errfd != 2 )				{					(void) close(malloc_errfd);				}			}						break;		default:			return(1);			break;	}	return(0);}/* * $Log:	mallopt.c,v $ * Revision 1.4  90/05/11  00:13:10  cpcahil * added copyright statment *  * Revision 1.3  90/02/25  11:03:26  cpcahil * changed to return int so that it agrees with l libmalloc.a's mallopt() *  * Revision 1.2  90/02/25  11:01:21  cpcahil * added support for malloc chain checking. *  * Revision 1.1  90/02/24  21:50:24  cpcahil * Initial revision *  * Revision 1.1  90/02/24  17:10:53  cpcahil * Initial revision *  */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -