summaryrefslogtreecommitdiff
path: root/Source/Library/Common
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Library/Common')
-rw-r--r--Source/Library/Common/CMem.ns.cpp14
-rw-r--r--Source/Library/Common/CMem.ns.h2
-rw-r--r--Source/Library/Common/String.class.cpp1
-rw-r--r--Source/Library/Common/String.class.h1
-rw-r--r--Source/Library/Common/cppsupport.wtf.cpp2
5 files changed, 15 insertions, 5 deletions
diff --git a/Source/Library/Common/CMem.ns.cpp b/Source/Library/Common/CMem.ns.cpp
index 37cdf0c..a4da4d2 100644
--- a/Source/Library/Common/CMem.ns.cpp
+++ b/Source/Library/Common/CMem.ns.cpp
@@ -3,9 +3,17 @@
namespace CMem {
//Standard C functions
-u8int *memcpy(u8int *dest, const u8int *src, int count) {
- for (int i = 0; i < count; i++) {
- dest[i] = src[i];
+u8int *memcpy(u8int *dest, const u8int *src, u32int count) {
+ u32int f = count % 4, n = count / 4;
+ const u32int* s = (u32int*)src;
+ u32int* d = (u32int*)dest;
+ for (u32int i = 0; i < n; i++) {
+ d[i] = s[i];
+ }
+ if (f != 0) {
+ for (u32int i = count - f; i < count; i++) {
+ dest[i] = src[i];
+ }
}
return dest;
}
diff --git a/Source/Library/Common/CMem.ns.h b/Source/Library/Common/CMem.ns.h
index f0c15da..aecddc9 100644
--- a/Source/Library/Common/CMem.ns.h
+++ b/Source/Library/Common/CMem.ns.h
@@ -6,7 +6,7 @@
//This namespace contains basic memory managment functions
namespace CMem {
- u8int *memcpy(u8int *dest, const u8int *src, int count);
+ u8int *memcpy(u8int *dest, const u8int *src, u32int count);
u8int *memset(u8int *dest, u8int val, int count);
u16int *memsetw(u16int *dest, u16int val, int count);
u32int strlen(const char *str);
diff --git a/Source/Library/Common/String.class.cpp b/Source/Library/Common/String.class.cpp
index fe851bd..8e958e0 100644
--- a/Source/Library/Common/String.class.cpp
+++ b/Source/Library/Common/String.class.cpp
@@ -195,6 +195,7 @@ String String::substr(s32int start, s32int size) {
if (size == 0) return String();
if (start < 0) start = m_length - start;
if (size == -1) size = m_length - start;
+ if (start + size >= (int)m_length) size = m_length - start;
String ret;
ret.m_string = new WChar[size + 1];
ret.m_length = size;
diff --git a/Source/Library/Common/String.class.h b/Source/Library/Common/String.class.h
index b623fb2..14f07f0 100644
--- a/Source/Library/Common/String.class.h
+++ b/Source/Library/Common/String.class.h
@@ -14,6 +14,7 @@ class String : public BasicString<WChar> {
String(const char* string, u8int encoding = UE_UTF8);
String() : BasicString<WChar>() {}
+ String(WChar c, u32int n = 1) : BasicString<WChar>(c, n) {}
String(const String &other) : BasicString<WChar> (other) {}
void affect(const char* string, u8int encoding = UE_UTF8);
diff --git a/Source/Library/Common/cppsupport.wtf.cpp b/Source/Library/Common/cppsupport.wtf.cpp
index 06ef1b9..59a78fc 100644
--- a/Source/Library/Common/cppsupport.wtf.cpp
+++ b/Source/Library/Common/cppsupport.wtf.cpp
@@ -2,7 +2,7 @@
#include <types.h>
namespace CMem {
- u8int* memcpy(u8int*, const u8int*, int);
+ u8int* memcpy(u8int*, const u8int*, u32int);
};
using namespace CMem;