added String constructor which takes (and clones) a ConstString

svn-id: r4918
This commit is contained in:
Max Horn 2002-09-09 11:42:24 +00:00
parent f277bb9fcd
commit 22e2df20c2
2 changed files with 17 additions and 1 deletions

View file

@ -37,6 +37,20 @@ String::String(const char *str)
}
}
String::String(const ConstString &str)
{
printf("String::String(const ConstString &str)\n");
_refCount = new int(1);
if (str._str) {
_capacity = _len = strlen(str._str);
_str = (char *)calloc(1, _capacity+1);
memcpy(_str, str._str, _len+1);
} else {
_capacity = _len = 0;
_str = 0;
}
}
String::String(const String &str)
{
++(*str._refCount);