浏览代码

base: fix a bug in the String fixed-size constructor.

legacy
Sam Hocevar sam 13 年前
父节点
当前提交
34948b7a0c
共有 1 个文件被更改,包括 6 次插入6 次删除
  1. +6
    -6
      src/lol/base/string.h

+ 6
- 6
src/lol/base/string.h 查看文件

@@ -14,8 +14,8 @@
// A very simple String class, based on Array. // A very simple String class, based on Array.
// //


#if !defined __LOL_CORE_STRING_H__
#define __LOL_CORE_STRING_H__
#if !defined __LOL_BASE_STRING_H__
#define __LOL_BASE_STRING_H__


#include <lol/base/array.h> #include <lol/base/array.h>


@@ -49,9 +49,9 @@ public:
: Super() : Super()
{ {
using namespace std; using namespace std;
Resize(count + 1);
memcpy(&(*this)[0], str, Count());
((Super &)*this).Last() = '\0';
Resize(count);
memcpy(&(*this)[0], str, count);
(*this)[count] = '\0';
} }


inline String(String const &s) inline String(String const &s)
@@ -146,5 +146,5 @@ public:


} /* namespace lol */ } /* namespace lol */


#endif // __LOL_CORE_STRING_H__
#endif // __LOL_BASE_STRING_H__



正在加载...
取消
保存