www.pudn.com > coremp4-1.0.zip > Memory.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#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 #include #include #ifdef LINUX #include #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 //----------------------------