📄 mem.bak
字号:
#ifndef __malloc_C__
#define __malloc_C__
#include "D:\gui\include\def.h"
#include "D:\gui\include\cfg.h"
static char *ptr=NULL;
static char *buffer=NULL;
static DT_INT nLen=0;
void MEM_Init(void* buff,DT_INT len)
{
buffer=buff;
ptr=buffer;
nLen=len;
}
void MEM_Quit()
{
ptr=buffer;
}
#if malloc_EN==1
void *malloc(DT_INT nSize)
{
void *ret;
if(ptr>=&buffer[nLen]-nSize) return NULL;
ret=(void*)ptr;
ptr+=nSize;
return ret;
}
#endif
#if free_EN==1
void *free(void *item)
{
if(!item) return NULL;
ptr=(char*)item;
return ptr;
}
#endif
#if memset_EN==1
void memset(void * buff,DT_CHAR nFill,DT_INT size)
{
DT_CHAR *item=buff;
while(size--)
{
*item++=nFill;
}
}
#endif
#if strcmp_EN==1
DT_CHAR strcmp(char *s1,char *s2)
{
DT_CHAR i;
while(1)
{
i=*s1-*s2;
if(i) return i;
if(*s1==0x00||*s2==0x00) break;
s1++;
s2++;
}
return 0;
}
#endif
#if strcpy_EN==1
void strcpy(char *s1,char *s2)
{
while(*s2)
{
*s1=*s2;
s2++;
s1++;
}
*s1=0;
}
#endif
#if strlen_EN==1
DT_INT strlen(char *s1)
{
DT_INT i=0;
while(*s1++) i++;
return i;
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -