xo-object2: beginning of DString + utest
This commit is contained in:
parent
fd02d9f834
commit
56bda48a06
7 changed files with 137 additions and 12 deletions
37
xo-object2/src/object2/DString.cpp
Normal file
37
xo-object2/src/object2/DString.cpp
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/** @file DString.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Jan 2026
|
||||
**/
|
||||
|
||||
#include "DString.hpp"
|
||||
|
||||
namespace xo {
|
||||
using xo::facet::typeseq;
|
||||
|
||||
namespace scm {
|
||||
DString *
|
||||
DString::empty(obj<AAllocator> mm,
|
||||
size_type cap)
|
||||
{
|
||||
assert(cap > 0);
|
||||
|
||||
DString * result = nullptr;
|
||||
|
||||
if (cap > 0) {
|
||||
void * mem = mm.alloc(typeseq::id<DString>(),
|
||||
sizeof(DString) + cap);
|
||||
|
||||
result = new (mem) DString();
|
||||
result->capacity_ = cap;
|
||||
result->size_ = 0;
|
||||
if (cap > 0) {
|
||||
result->chars_[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end DString.cpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue