📄 gmem.h
字号:
/*
* Copyright (C) Obigo AB, 2002-2005.
* All rights reserved.
*
* This software is covered by the license agreement between
* the end user and Obigo AB, and may be
* used and copied only in accordance with the terms of the
* said agreement.
*
* Obigo AB assumes no responsibility or
* liability for any errors or inaccuracies in this software,
* or any consequential, incidental or indirect damage arising
* out of the use of the software.
*
*/
#ifndef _GMEM_H
#define _GMEM_H
#ifndef _CMNCONF_H
#error You must #include cmnconf.h before this file. Otherwise it will not work!
#error The file cmnconf.h contains configuration data for all other common files.
#error Please change the .c file that stopped from compiling because you came here
#error so that it includes cmnconf.h before gmem.h. If you think that this is ugly,
#error please come up with a better and simple solution ;-)
#endif
typedef unsigned long MemSize;
typedef void *MemPtr;
#if CMN_LOG_INTERNAL & CMN_LOG_MEMORY
#define G_CALLOC(id, s) memset( gMemAlloc(id, s, __FILE__, __LINE__), 0, s)
#define G_ALLOC(id, s) gMemAlloc(id, s, __FILE__, __LINE__)
#define G_ALLOCTYPE(id, t) (t *)gMemAlloc(id, sizeof (t), __FILE__, __LINE__)
#define G_FREE(id, p) { gMemFree(id, p, __FILE__, __LINE__); (p)=NULL; }
MemPtr gMemAlloc(CmnClientId id, MemSize size, const char *filename, int lineno);
void gMemFree(CmnClientId id, MemPtr p, const char *filename, int lineno);
#else
#define G_CALLOC(id, s) memset( gMemAlloc(id, s), 0, s)
#define G_ALLOC(id, s) gMemAlloc(id, s)
#define G_ALLOCTYPE(id, t) (t *)gMemAlloc(id, sizeof (t))
#define G_FREE(id, p) { gMemFree(id, p); (p)=NULL; }
MemPtr gMemAlloc(CmnClientId id, MemSize size);
void gMemFree(CmnClientId id, MemPtr p);
#endif
short gMemInit(CmnClientId id, MemPtr mem, MemSize memsize);
jmp_buf *gMemGetJmpBuf(CmnClientId id);
int gMemGetInside(CmnClientId id);
void gMemSetInside(CmnClientId id, int inside);
void gMemTerminate(CmnClientId id);
MemPtr gMemMalloc(CmnClientId id, MemSize size);
MemPtr gMemGcMalloc(CmnClientId id, MemSize size);
void gMemGc(CmnClientId id);
MemSize gMemSize(MemPtr mem);
#if CMN_LOG_INTERNAL & CMN_LOG_MEMORY
typedef struct
{
int bytesAllocated;
int bytesRequested;
int currentlyAllocated;
int maxAllocated;
int lastAlloc;
int lastReq;
int numAlloc;
int numFree;
int traverseCount;
int maxFreeListLength;
} MallocStats;
void gMemPrintAlloc(CmnClientId id, FILE *logfile);
void gMemPrintChunks(CmnClientId id, FILE *logfile);
void gMemPrintClients(FILE *logfile);
void gMemPrintFreeList(CmnClientId id, FILE *logfile);
void gMemPrintBriefStats(CmnClientId id, FILE *logfile);
MallocStats *gMemGetStats(CmnClientId id);
short gMemGetFragmentation(CmnClientId id);
void gMemPrintFragmentationStats(CmnClientId id, FILE *logfile);
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -