-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstring.cpp
More file actions
42 lines (33 loc) · 716 Bytes
/
string.cpp
File metadata and controls
42 lines (33 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
@file
Run-time string
@copyright Denis Priyomov 2017
Distributed under the MIT License
(See accompanying file LICENSE or visit https://github.com/cppden/ctstring)
*/
#include <cstring>
#include "string.hpp"
namespace cts {
/*
* explicit_bzero is from public domain. Written by Matthew Dempsky.
*/
__attribute__((weak)) void __explicit_bzero_hook(void* buf, std::size_t len)
{
}
void explicit_bzero(void* buf, std::size_t len)
{
std::memset(buf, 0, len);
__explicit_bzero_hook(buf, len);
}
string::~string()
{
if (!m_str.empty())
{
explicit_bzero(m_str.data(), m_str.size());
}
}
std::ostream& operator<< (std::ostream& out, string const& s)
{
return out << s.c_str();
}
} //end: namespace cts