From bb1c73658ccfae9306bdf769d4314d3e14bf9a74 Mon Sep 17 00:00:00 2001 From: Spoike Date: Thu, 1 Dec 2005 01:21:08 +0000 Subject: [PATCH] Added memset, memcpy, and memmove for efficency (rather than implementing them in a qvm). git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1644 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/common/plugin.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/engine/common/plugin.c b/engine/common/plugin.c index bf11f3692..2631904d0 100644 --- a/engine/common/plugin.c +++ b/engine/common/plugin.c @@ -1083,6 +1083,34 @@ int VARGS Plug_FS_Open(void *offset, unsigned int mask, const long *arg) return -2; } +int VARGS Plug_memset(void *offset, unsigned int mask, const long *arg) +{ + if (VM_OOB(arg[0], arg[2])) + return false; + + memset(VM_POINTER(arg[0]), VM_LONG(arg[1]), VM_LONG(arg[2])); + return arg[0]; +} +int VARGS Plug_memcpy(void *offset, unsigned int mask, const long *arg) +{ + if (VM_OOB(arg[0], arg[2])) + return false; + if (VM_OOB(arg[1], arg[2])) + return false; + + memcpy(VM_POINTER(arg[0]), VM_POINTER(arg[1]), VM_LONG(arg[2])); + return arg[0]; +} +int VARGS Plug_memmove(void *offset, unsigned int mask, const long *arg) +{ + if (VM_OOB(arg[0], arg[2])) + return false; + if (VM_OOB(arg[1], arg[2])) + return false; + + memmove(VM_POINTER(arg[0]), VM_POINTER(arg[1]), VM_LONG(arg[2])); + return arg[0]; +} int VARGS Plug_Net_Recv(void *offset, unsigned int mask, const long *arg) { @@ -1336,6 +1364,11 @@ void Plug_Init(void) Plug_RegisterBuiltin("FS_Close", Plug_Net_Close, 0); + Plug_RegisterBuiltin("memset", Plug_memset, 0); + Plug_RegisterBuiltin("memcpy", Plug_memcpy, 0); + Plug_RegisterBuiltin("memmove", Plug_memmove, 0); + + Plug_RegisterBuiltin("Media_ShowFrameRGBA_32", Plug_Media_ShowFrameRGBA_32, 0); if (plug_loaddefault.value)