xref: /haiku/src/add-ons/kernel/file_systems/packagefs/util/String.cpp (revision 9f81ca838ce7b92b5689e57d3f86765db4705a7b)
1 /*
2  * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include "String.h"
8 
9 
10 bool
SetToExactLength(const char * string,size_t length)11 String::SetToExactLength(const char* string, size_t length)
12 {
13 	StringData* data = StringPool::Get(string, length);
14 	if (data == NULL)
15 		return false;
16 
17 	fData->ReleaseReference();
18 	fData = data;
19 	return true;
20 }
21 
22 
23 String&
operator =(const String & other)24 String::operator=(const String& other)
25 {
26 	if (this == &other)
27 		return *this;
28 
29 	fData->ReleaseReference();
30 	fData = other.fData;
31 	fData->AcquireReference();
32 
33 	return *this;
34 }
35