summaryrefslogtreecommitdiff
path: root/Source/Kernel/Library
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-08-29 15:20:49 +0200
committerAlexis211 <alexis211@gmail.com>2009-08-29 15:20:49 +0200
commit0139012d683036fb661fed62babb71f59ec9ab45 (patch)
treea3be3c9fef99ee5a39357491df6e4a530b1636f6 /Source/Kernel/Library
parentc92beeedda51487696ce476ee30604f22e7b2270 (diff)
downloadMelon-0139012d683036fb661fed62babb71f59ec9ab45.tar.gz
Melon-0139012d683036fb661fed62babb71f59ec9ab45.zip
.
Diffstat (limited to 'Source/Kernel/Library')
-rw-r--r--Source/Kernel/Library/.String.class.cpp.swpbin0 -> 20480 bytes
-rw-r--r--Source/Kernel/Library/String.class.cpp16
2 files changed, 16 insertions, 0 deletions
diff --git a/Source/Kernel/Library/.String.class.cpp.swp b/Source/Kernel/Library/.String.class.cpp.swp
new file mode 100644
index 0000000..6fd369f
--- /dev/null
+++ b/Source/Kernel/Library/.String.class.cpp.swp
Binary files differ
diff --git a/Source/Kernel/Library/String.class.cpp b/Source/Kernel/Library/String.class.cpp
index dc763bd..c118800 100644
--- a/Source/Kernel/Library/String.class.cpp
+++ b/Source/Kernel/Library/String.class.cpp
@@ -56,6 +56,10 @@ String::String() {
String::String(char* string) {
m_length = strlen(string);
+ if (m_length == 0) {
+ m_string = 0;
+ return;
+ }
m_string = (char*)Mem::kalloc(m_length + 1);
for (u32int i = 0; i < m_length; i++) {
m_string[i] = string[i];
@@ -65,6 +69,10 @@ String::String(char* string) {
String::String(const String &other) {
m_length = other.m_length;
+ if (m_length == 0) {
+ m_string = 0;
+ return;
+ }
m_string = (char*)Mem::kalloc(m_length + 1);
for (u32int i = 0; i < m_length; i++) {
m_string[i] = other.m_string[i];
@@ -79,6 +87,10 @@ String::~String() {
void String::operator= (const String &other) {
m_length = other.m_length;
if (m_string != 0) Mem::kfree(m_string);
+ if (m_length == 0) {
+ m_string = 0;
+ return;
+ }
m_string = (char*)Mem::kalloc(m_length + 1);
for (u32int i = 0; i < m_length; i++) {
m_string[i] = other.m_string[i];
@@ -89,6 +101,10 @@ void String::operator= (const String &other) {
void String::operator= (char* string) {
m_length = strlen(string);
if (m_string != 0) Mem::kfree(m_string);
+ if (m_length == 0) {
+ m_string = 0;
+ return;
+ }
m_string = (char*)Mem::kalloc(m_length + 1);
for (u32int i = 0; i < m_length; i++) {
m_string[i] = string[i];