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

📄 m_osip_port.h

📁 一个在linux下跟踪内存泄露的小程序,一般在linux下可以用 mtrace valgrind来做,但是在嵌入式上,由于内存的限制,mtrace valgrind都显得束手无策
💻 H
字号:
/*
  The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
  Copyright (C) 2001,2002,2003,2004  Aymeric MOIZARD jack@atosc.org
  
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.
  
  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.
  
  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/


#ifndef _M_OSIP_PORT_H_
#define _M_OSIP_PORT_H_

#include <stdio.h>
#define BTDEPTH  100   //back trace的最大深度
typedef struct _traceinfo
{
   size_t size;
   char **strings;
}TraceInfo_t;
	typedef struct M_log
        {
		void *p;  //申请,释放的地址
		char file[32];  //文件
                char func[32];    //函数名
		unsigned short  line;  //行
                int size;    //大小
         #ifdef DBGMEM_TRACE   //如果跟踪堆栈,可能会耗更多一些内存,如果内存充裕可以用这种方式
               TraceInfo_t traceinfo; //
         #endif
	}M_log_t;

#ifdef DBGMEM_SAVE2FILE
void DebugMemoryBegin(char *fname);
#else
void DebugMemoryBegin(void);
#endif
      void DebugMemoryEnd(void);
	void *_DebugMemory_malloc (size_t size, char *file, char *func, unsigned short line);
	void _DebugMemory_free (void *ptr);
	void *_DebugMemory_realloc (void *ptr, size_t size, char *file, char *func, unsigned short line);

#if defined(DBGMEM) || defined(DBGMEM_TRACE) || defined(DBGMEM_SAVE2FILE)

#ifndef DBGMEM_malloc
#define DBGMEM_malloc(S) _DebugMemory_malloc(S,__FILE__,__FUNCTION__,__LINE__)
#endif
#ifndef DBGMEM_realloc
#define DBGMEM_realloc(P,S) _DebugMemory_realloc(P,S,__FILE__,__FUNCTION__,__LINE__)
#endif
#ifndef DBGMEM_free
#define DBGMEM_free(P) { if (P!=NULL) { _DebugMemory_free(P); } }
#endif

#else

#ifndef DBGMEM_malloc
#define DBGMEM_malloc(S) malloc(S)
#endif
#ifndef DBGMEM_realloc
#define DBGMEM_realloc(P,S) realloc(P,S)
#endif
#ifndef DBGMEM_free
#define DBGMEM_free(P) { if (P!=NULL) { free(P); } }
#endif

#endif

#endif                          /* _PORT_H_ */

⌨️ 快捷键说明

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