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

📄 memory.cpp

📁 鼎鼎有名的手机mpeg4播放器smart movie-智能影院 解码内核
💻 CPP
字号:
/*****************************************************************************
 *
 * This program is free software ; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 *
 ****************************************************************************/

#ifdef __SYMBIAN32__
#include <e32base.h>
#endif
#include "Util.h"

//----------------------------

#ifdef __SYMBIAN32__

void MemSet(void *dst, byte c, dword len){
   Mem::Fill(dst, len, c);
}

//----------------------------

void MemCpy(void *dst, const void *src, dword len){
   Mem::Copy(dst, src, len);
}

//----------------------------

int MemCmp(const void *mem1, const void *mem2, dword len){
   return Mem::Compare((byte*)mem1, len, (byte*)mem2, len);
}

//----------------------------

void *operator new(size_t sz, bool){
   void *vp = operator new(sz);
   if(!vp)
      User::Panic(_L("Failed to alloc memory"), sz);
   return vp;
}

//----------------------------

void Fatal(const char *msg, dword code){

   int len = User::StringLength((const byte*)msg);
   TBuf16<20> desc; desc.Copy(TPtr8((byte*)msg, Min(len, 20), len));
   User::Panic(desc, code);
}

//----------------------------
#elif defined _WINDOWS || defined _WIN32_WCE || defined LINUX

#include <Memory.h>
#include <String.h>
#include <Windows.h>
#ifdef LINUX
#include <wchar.h>
#endif

//----------------------------

void MemSet(void *dst, byte c, dword len){
   memset(dst, c, len);
}

//----------------------------

void MemCpy(void *dst, const void *src, dword len){
   memcpy(dst, src, len);
}

//----------------------------

int MemCmp(const void *mem1, const void *mem2, dword len){
   return memcmp(mem1, mem2, len);
}

//----------------------------

void Fatal(const char *msg, dword code){

   wchar tmp[128];
   int i;
   for(i=0; msg[i]; i++)
      tmp[i] = msg[i];
   tmp[i] = 0;
   MessageBox(NULL, tmp, L"Fatal Error", MB_OK | MB_ICONERROR);

   exit(1);
}

//----------------------------

void *operator new(size_t sz, bool){
   void *vp = new byte[sz];
   if(!vp){
                              //todo: fatal error
      Fatal("Failed to alloc memory", sz);
      return NULL;
   }
   return vp;
}

//----------------------------

#endif
//----------------------------

⌨️ 快捷键说明

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