Explicit CopyString, remove (const char*) constructors.

This gets rid of the (litstr) StringData and StackStringData
constructors, but keeps String(litstr).  Also rename all
the instances of AttachLiteral to CopyString, since they now
mean the same thing.
Esse commit está contido em:
Edwin Smith
2013-04-24 16:57:54 -07:00
commit de Sara Golemon
commit b7cc57a8db
55 arquivos alterados com 178 adições e 180 exclusões
+1 -1
Ver Arquivo
@@ -781,7 +781,7 @@ void FunctionScope::setParamName(int index, const std::string &name) {
void FunctionScope::setParamDefault(int index, const char* value, int64_t len,
const std::string &text) {
assert(index >= 0 && index < (int)m_paramNames.size());
StringData* sd = new StringData(value, len, AttachLiteral);
StringData* sd = new StringData(value, len, CopyString);
sd->setStatic();
m_paramDefaults[index] = String(sd);
m_paramDefaultTexts[index] = text;
+2 -2
Ver Arquivo
@@ -390,13 +390,13 @@ std::string Option::MangleFilename(const std::string &name, bool id) {
bool Option::IsFileExcluded(const std::string &file,
const std::set<std::string> &patterns) {
String sfile(file.c_str(), file.size(), AttachLiteral);
String sfile(file.c_str(), file.size(), CopyString);
for (set<string>::const_iterator iter = patterns.begin();
iter != patterns.end(); ++iter) {
const std::string &pattern = *iter;
Variant matches;
Variant ret = preg_match(String(pattern.c_str(), pattern.size(),
AttachLiteral), sfile, matches);
CopyString), sfile, matches);
if (ret.toInt64() > 0) {
return true;
}
+9 -9
Ver Arquivo
@@ -375,7 +375,7 @@ inline bool same(const StringData *v1, CStrRef v2) {
return same(v1, v2.get());
}
inline bool same(const StringData *v1, litstr v2) {
StackStringData sd2(v2);
StackStringData sd2(v2, CopyString);
return same(v1, &sd2);
}
inline bool same(const StringData *v1, CArrRef v2) { return false; }
@@ -396,7 +396,7 @@ inline bool equal(const StringData *v1, CStrRef v2) {
return equal(v1, v2.get());
}
inline bool equal(const StringData *v1, litstr v2) {
StackStringData sd2(v2);
StackStringData sd2(v2, CopyString);
return equal(v1, &sd2);
}
inline bool equal(const StringData *v1, CArrRef v2) {
@@ -464,7 +464,7 @@ inline bool less(const StringData *v1, CStrRef v2) {
return less(v1, v2.get());
}
inline bool less(const StringData *v1, litstr v2) {
StackStringData sd2(v2);
StackStringData sd2(v2, CopyString);
return less(v1, &sd2);
}
inline bool less(const StringData *v1, CArrRef v2) {
@@ -501,7 +501,7 @@ inline bool more(const StringData *v1, CStrRef v2) {
return more(v1, v2.get());
}
inline bool more(const StringData *v1, litstr v2) {
StackStringData sd2(v2);
StackStringData sd2(v2, CopyString);
return more(v1, &sd2);
}
inline bool more(const StringData *v1, CArrRef v2) {
@@ -607,7 +607,7 @@ inline bool same(litstr v1, int v2) { return same(String(v1), v2);}
inline bool same(litstr v1, int64_t v2) { return same(String(v1), v2);}
inline bool same(litstr v1, double v2) { return same(String(v1), v2);}
inline bool same(litstr v1, const StringData *v2) {
StackStringData sd1(v1);
StackStringData sd1(v1, CopyString);
return same(&sd1, v2);
}
inline bool same(litstr v1, CStrRef v2) { return same(String(v1), v2);}
@@ -621,7 +621,7 @@ inline bool equal(litstr v1, int v2) { return equal(String(v1),v2);}
inline bool equal(litstr v1, int64_t v2) { return equal(String(v1),v2);}
inline bool equal(litstr v1, double v2) { return equal(String(v1),v2);}
inline bool equal(litstr v1, const StringData *v2) {
StackStringData sd1(v1);
StackStringData sd1(v1, CopyString);
return equal(&sd1, v2);
}
inline bool equal(litstr v1, CStrRef v2) { return equal(String(v1),v2);}
@@ -640,7 +640,7 @@ inline bool equalAsStr(litstr v1, const StringData *v2) {
inline bool equalAsStr(litstr v1, CStrRef v2) { return equalAsStr(v2, v1);}
inline bool equalAsStr(litstr v1, litstr v2) { return same(v1, v2);}
inline bool equalAsStr(litstr v1, CArrRef v2) {
StackStringData sd1(v1);
StackStringData sd1(v1, CopyString);
return equalAsStr(&sd1, v2);
}
inline bool equalAsStr(litstr v1, CObjRef v2) {
@@ -653,7 +653,7 @@ inline bool less(litstr v1, int v2) { return less(String(v1), v2);}
inline bool less(litstr v1, int64_t v2) { return less(String(v1), v2);}
inline bool less(litstr v1, double v2) { return less(String(v1), v2);}
inline bool less(litstr v1, const StringData *v2) {
StackStringData sd1(v1);
StackStringData sd1(v1, CopyString);
return less(&sd1, v2);
}
inline bool less(litstr v1, CStrRef v2) { return less(String(v1), v2);}
@@ -667,7 +667,7 @@ inline bool more(litstr v1, int v2) { return more(String(v1), v2);}
inline bool more(litstr v1, int64_t v2) { return more(String(v1), v2);}
inline bool more(litstr v1, double v2) { return more(String(v1), v2);}
inline bool more(litstr v1, const StringData *v2) {
StackStringData sd1(v1);
StackStringData sd1(v1, CopyString);
return more(&sd1, v2);
}
inline bool more(litstr v1, CStrRef v2) { return more(String(v1), v2);}
+2 -2
Ver Arquivo
@@ -479,9 +479,9 @@ static bool matchHdfPattern(const std::string &value, Hdf hdfPattern) {
string pattern = hdfPattern.getString();
if (!pattern.empty()) {
Variant ret = preg_match(String(pattern.c_str(), pattern.size(),
AttachLiteral),
CopyString),
String(value.c_str(), value.size(),
AttachLiteral));
CopyString));
if (ret.toInt64() <= 0) {
return false;
}
+2 -2
Ver Arquivo
@@ -31,9 +31,9 @@ FilesMatch::FilesMatch(Hdf vh) {
bool FilesMatch::match(const std::string &filename) const {
if (!m_pattern.empty()) {
Variant ret = preg_match(String(m_pattern.c_str(), m_pattern.size(),
AttachLiteral),
CopyString),
String(filename.c_str(), filename.size(),
AttachLiteral));
CopyString));
return ret.toInt64() > 0;
}
return false;
+1 -1
Ver Arquivo
@@ -173,7 +173,7 @@ void HttpProtocol::PrepareSystemVariables(Transport *transport,
} else {
// For literal we disregard RuntimeOption::AlwaysPopulateRawPostData
if (uint32_t(size) <= StringData::MaxSize) {
g->GV(HTTP_RAW_POST_DATA) = String((char*)data, size, AttachLiteral);
g->GV(HTTP_RAW_POST_DATA) = String((char*)data, size, CopyString);
}
}
}
@@ -400,10 +400,10 @@ bool HttpRequestHandler::handleProxyRequest(Transport *transport, bool force) {
bool HttpRequestHandler::MatchAnyPattern
(const std::string &path, const std::vector<std::string> &patterns) {
String spath(path.c_str(), path.size(), AttachLiteral);
String spath(path.c_str(), path.size(), CopyString);
for (unsigned int i = 0; i < patterns.size(); i++) {
Variant ret = preg_match(String(patterns[i].c_str(), patterns[i].size(),
AttachLiteral),
CopyString),
spath);
if (ret.toInt64() > 0) return true;
}
@@ -199,7 +199,7 @@ bool RPCRequestHandler::executePHPFunction(Transport *transport,
int size;
const void *data = transport->getPostData(size);
if (data && size) {
params.append(String((char*)data, size, AttachLiteral));
params.append(String((char*)data, size, CopyString));
}
}
}
+2 -2
Ver Arquivo
@@ -81,11 +81,11 @@ public:
}
virtual bool shouldHandle(const std::string &cmd) {
String url(cmd.c_str(), cmd.size(), AttachLiteral);
String url(cmd.c_str(), cmd.size(), CopyString);
for (set<string>::const_iterator iter = m_allowedURLs.begin();
iter != m_allowedURLs.end(); ++iter) {
Variant ret = preg_match
(String(iter->c_str(), iter->size(), AttachLiteral), url);
(String(iter->c_str(), iter->size(), CopyString), url);
if (ret.toInt64() > 0) {
return true;
}
+2 -2
Ver Arquivo
@@ -54,12 +54,12 @@ Server::Server(const std::string &address, int port, int threadCount)
}
bool Server::shouldHandle(const std::string &cmd) {
String url(cmd.c_str(), cmd.size(), AttachLiteral);
String url(cmd.c_str(), cmd.size(), CopyString);
for (std::set<string>::const_iterator iter =
SatelliteServerInfo::InternalURLs.begin();
iter != SatelliteServerInfo::InternalURLs.end(); ++iter) {
Variant ret = preg_match
(String(iter->c_str(), iter->size(), AttachLiteral), url);
(String(iter->c_str(), iter->size(), CopyString), url);
if (ret.toInt64() > 0) {
return false;
}
+6 -11
Ver Arquivo
@@ -158,8 +158,8 @@ void ServerStats::Filter(list<TimeSlot*> &slots, const std::string &keys,
const string &rule = riter->first;
if (rule[0] == ':') {
Variant ret = preg_match(String(rule.c_str(), rule.size(),
AttachLiteral),
String(key.c_str(), key.size(), AttachLiteral));
CopyString),
String(key.c_str(), key.size(), CopyString));
if (!same(ret, false) && more(ret, 0)) {
wantedKeys[key] |= riter->second;
}
@@ -307,7 +307,7 @@ void ServerStats::FreeSlots(list<TimeSlot*> &slots) {
class Writer {
public:
Writer(ostream &out) : m_out(out), m_indent(0) {}
explicit Writer(ostream &out) : m_out(out), m_indent(0) {}
virtual ~Writer() {}
virtual void writeFileHeader() = 0;
@@ -350,8 +350,7 @@ protected:
class XMLWriter : public Writer {
public:
XMLWriter(ostream &out) : Writer(out) {}
explicit XMLWriter(ostream &out) : Writer(out) {}
virtual void writeFileHeader() {
m_out << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
@@ -483,10 +482,7 @@ protected:
}
public:
JSONWriter(ostream &out) : Writer(out),
m_justIndented(true) {
explicit JSONWriter(ostream &out) : Writer(out), m_justIndented(true) {
// A valid json object begins in the nameless context. See
// json.org for JSON state machine.
m_namelessContextStack.push(true);
@@ -533,9 +529,8 @@ public:
};
class HTMLWriter : public Writer {
public:
HTMLWriter(ostream &out) : Writer(out) {}
explicit HTMLWriter(ostream &out) : Writer(out) {}
virtual void writeFileHeader() {
m_out << "<!doctype html>\n<html>\n<head>\n"
+1 -1
Ver Arquivo
@@ -37,7 +37,7 @@ SourceRootInfo::SourceRootInfo(const char *host)
Variant matches;
Variant r = preg_match(String(RuntimeOption::SandboxPattern.c_str(),
RuntimeOption::SandboxPattern.size(),
AttachLiteral), host, matches);
CopyString), host, matches);
if (!r.same(1)) {
m_sandboxCond = SandboxOff;
return;
+2 -2
Ver Arquivo
@@ -614,7 +614,7 @@ void Transport::prepareHeaders(bool compressed, const void *data, int size) {
addHeaderImpl("Content-Encoding", "gzip");
removeHeaderImpl("Content-Length");
if (m_responseHeaders.find("Content-MD5") != m_responseHeaders.end()) {
String response((const char *)data, size, AttachLiteral);
String response((const char *)data, size, CopyString);
removeHeaderImpl("Content-MD5");
addHeaderImpl("Content-MD5", StringUtil::Base64Encode(
StringUtil::MD5(response, true)).c_str());
@@ -663,7 +663,7 @@ void Transport::prepareHeaders(bool compressed, const void *data, int size) {
String Transport::prepareResponse(const void *data, int size, bool &compressed,
bool last) {
String response((const char *)data, size, AttachLiteral);
String response((const char *)data, size, CopyString);
// we don't use chunk encoding to send anything pre-compressed
assert(!compressed || !m_chunkedEncoding);
+9 -9
Ver Arquivo
@@ -263,9 +263,9 @@ void VirtualHost::init(Hdf vh) {
bool VirtualHost::match(const string &host) const {
if (!m_pattern.empty()) {
Variant ret = preg_match(String(m_pattern.c_str(), m_pattern.size(),
AttachLiteral),
CopyString),
String(host.c_str(), host.size(),
AttachLiteral));
CopyString));
return ret.toInt64() > 0;
} else if (!m_prefix.empty()) {
return strncasecmp(host.c_str(), m_prefix.c_str(), m_prefix.size()) == 0;
@@ -304,7 +304,7 @@ bool VirtualHost::rewriteURL(CStrRef host, String &url, bool &qsa,
subject = host;
}
Variant ret = preg_match(String(it->pattern.c_str(), it->pattern.size(),
AttachLiteral), subject);
CopyString), subject);
if (!ret.same(it->negate ? 0 : 1)) {
passed = false;
break;
@@ -379,9 +379,9 @@ std::string VirtualHost::serverName(const std::string &host) const {
if (!m_pattern.empty()) {
Variant matches;
Variant ret = preg_match(String(m_pattern.c_str(), m_pattern.size(),
AttachLiteral),
CopyString),
String(host.c_str(), host.size(),
AttachLiteral),
CopyString),
matches);
if (ret.toInt64() > 0) {
String prefix = matches[1].toString();
@@ -414,9 +414,9 @@ std::string VirtualHost::filterUrl(const std::string &url) const {
if (!filter.urlPattern.empty()) {
Variant ret = preg_match(String(filter.urlPattern.c_str(),
filter.urlPattern.size(),
AttachLiteral),
CopyString),
String(url.c_str(), url.size(),
AttachLiteral));
CopyString));
match = (ret.toInt64() > 0);
}
@@ -429,9 +429,9 @@ std::string VirtualHost::filterUrl(const std::string &url) const {
int count = preg_replace(ret, filter.namePattern.c_str(),
String(filter.replaceWith.c_str(),
filter.replaceWith.size(),
AttachLiteral),
CopyString),
String(url.c_str(), url.size(),
AttachLiteral));
CopyString));
if (!same(ret, false) && count > 0) {
return ret.toString().data();
}
@@ -325,7 +325,7 @@ static int64_t get_int64_value(StoreValue* sval) {
v = sval->var->toLocal();
} else {
assert(sval->inFile());
String s(sval->sAddr, sval->getSerializedSize(), AttachLiteral);
String s(sval->sAddr, sval->getSerializedSize(), CopyString);
v = apc_unserialize(s);
}
return v.toInt64();
@@ -498,7 +498,7 @@ void ConcurrentTableSharedStore::prime
continue;
}
if (RuntimeOption::APCSizeCountPrime) {
StackStringData sd(copy);
StackStringData sd(copy, CopyString);
stats_on_add(&sd, &acc->second, 0, true, false);
}
}
@@ -601,7 +601,7 @@ void ConcurrentTableSharedStore::dump(std::ostream & out, bool keyOnly,
assert(sval->inFile());
// we need unserialize and serialize again because the format was
// APCSerialize
String s(sval->sAddr, sval->getSerializedSize(), AttachLiteral);
String s(sval->sAddr, sval->getSerializedSize(), CopyString);
value = apc_unserialize(s);
}
try {
+2 -2
Ver Arquivo
@@ -140,7 +140,7 @@ Variant SharedVariant::toLocal() {
{
if (getSerializedArray()) {
return apc_unserialize(String(m_data.str->data(), m_data.str->size(),
AttachLiteral));
CopyString));
}
return NEW(SharedMap)(this);
}
@@ -156,7 +156,7 @@ Variant SharedVariant::toLocal() {
return m_data.obj->getObject();
}
return apc_unserialize(String(m_data.str->data(), m_data.str->size(),
AttachLiteral));
CopyString));
}
}
}
+3 -3
Ver Arquivo
@@ -106,12 +106,12 @@ StringData* StringData::FindStaticString(const StringData* str) {
}
StringData *StringData::GetStaticString(const std::string &str) {
StackStringData sd(str.c_str(), str.size(), AttachLiteral);
StackStringData sd(str.c_str(), str.size(), CopyString);
return GetStaticString(&sd);
}
StringData *StringData::GetStaticString(const char *str) {
StackStringData sd(str, strlen(str), AttachLiteral);
StackStringData sd(str, strlen(str), CopyString);
return GetStaticString(&sd);
}
@@ -565,7 +565,7 @@ static StringData** precompute_chars() {
StringData** raw = new StringData*[256];
for (int i = 0; i < 256; i++) {
char s[2] = { (char)i, 0 };
StackStringData str(s, 1, AttachLiteral);
StackStringData str(s, 1, CopyString);
raw[i] = StringData::GetStaticString(&str);
}
return raw;
+7 -8
Ver Arquivo
@@ -58,7 +58,7 @@ enum AttachStringMode { AttachString };
// const char* points to client-owned memory, StringData will copy it
// at construct-time using smart_malloc. This is only ok when the StringData
// itself was smart-allocated.
enum CopyStringMode { CopyString, AttachLiteral = CopyString };
enum CopyStringMode { CopyString };
// reserve space for buffer that will be filled in by client.
enum ReserveStringMode { ReserveString };
@@ -147,9 +147,6 @@ class StringData {
* Different ways of constructing StringData. Default constructor at above
* is actually only for SmartAllocator to pre-allocate the objects.
*/
explicit StringData(const char* data) {
initCopy(data);
}
StringData(const char *data, AttachStringMode) {
initAttach(data);
}
@@ -421,12 +418,14 @@ public:
class StackStringData : public StringData {
public:
StackStringData() { incRefCount(); }
explicit StackStringData(const char* s) : StringData(s) { incRefCount(); }
template <class T>
StackStringData(const char* s, T p) : StringData(s, p) { incRefCount(); }
StackStringData(const char* s, T p) : StringData(s, p) {
incRefCount();
}
template <class T>
StackStringData(const char* s, int len, T p) :
StringData(s, len, p) { incRefCount(); }
StackStringData(const char* s, int len, T p) : StringData(s, len, p) {
incRefCount();
}
~StackStringData() {
// verify that no references escaped
+1 -1
Ver Arquivo
@@ -301,7 +301,7 @@ Variant StringUtil::ChunkSplit(CStrRef body, int chunklen /* = 76 */,
String StringUtil::CEncode(CStrRef input, CStrRef charlist) {
String chars = charlist;
if (chars.isNull()) {
chars = String("\\\x00\x01..\x1f\x7f..\xff", 10, AttachLiteral);
chars = String("\\\x00\x01..\x1f\x7f..\xff", 10, CopyString);
}
if (input.empty() || chars.empty()) return input;
int len = input.size();
+2 -2
Ver Arquivo
@@ -151,7 +151,7 @@ Array TimeZone::GetNames() {
Array ret;
for (int i = 0; i < item_count; ++i) {
ret.append(String(table[i].id, AttachLiteral));
ret.append(String(table[i].id, CopyString));
}
return ret;
}
@@ -168,7 +168,7 @@ Array TimeZone::GetAbbreviations() {
element.set(s_dst, (bool)entry->type);
element.set(s_offset, entry->gmtoffset);
if (entry->full_tz_name) {
element.set(s_timezone_id, String(entry->full_tz_name, AttachLiteral));
element.set(s_timezone_id, String(entry->full_tz_name, CopyString));
} else {
element.set(s_timezone_id, uninit_null());
}
+15 -5
Ver Arquivo
@@ -51,7 +51,9 @@ inline char toByte(short v) { return v;}
inline char toByte(int v) { return v;}
inline char toByte(int64_t v) { return v;}
inline char toByte(double v) { return (char)v;}
inline char toByte(litstr v) { return StringData(v).toByte();}
inline char toByte(litstr v) {
return StringData(v, CopyString).toByte();
}
inline char toByte(const StringData *v) { return v ? v->toByte() : 0;}
inline char toByte(CStrRef v) { return toByte(v.get());}
inline char toByte(const ArrayData *v) { return (v && !v->empty()) ? 1 : 0;}
@@ -66,7 +68,9 @@ inline short toInt16(short v) { return v;}
inline short toInt16(int v) { return v;}
inline short toInt16(int64_t v) { return v;}
inline short toInt16(double v) { return (short)v;}
inline short toInt16(litstr v) { return StringData(v).toInt16();}
inline short toInt16(litstr v) {
return StringData(v, CopyString).toInt16();
}
inline short toInt16(const StringData *v) { return v ? v->toInt16() : 0;}
inline short toInt16(CStrRef v) { return toInt16(v.get());}
inline short toInt16(const ArrayData *v) { return (v && !v->empty()) ? 1 : 0;}
@@ -81,7 +85,9 @@ inline int toInt32(short v) { return v;}
inline int toInt32(int v) { return v;}
inline int toInt32(int64_t v) { return v;}
inline int toInt32(double v) { return (int)v;}
inline int toInt32(litstr v) { return StringData(v).toInt32();}
inline int toInt32(litstr v) {
return StringData(v, CopyString).toInt32();
}
inline int toInt32(const StringData *v) { return v ? v->toInt32() : 0;}
inline int toInt32(CStrRef v) { return toInt32(v.get());}
inline int toInt32(const ArrayData *v) { return (v && !v->empty()) ? 1 : 0;}
@@ -103,7 +109,9 @@ inline int64_t toInt64(double v) {
? (v > std::numeric_limits<uint64_t>::max() ? 0u : (uint64_t)v)
: (v < 0 ? (int64_t)v : std::numeric_limits<int64_t>::min()));
}
inline int64_t toInt64(litstr v) { return StringData(v).toInt64();}
inline int64_t toInt64(litstr v) {
return StringData(v, CopyString).toInt64();
}
inline int64_t toInt64(const StringData *v) { return v ? v->toInt64() : 0;}
inline int64_t toInt64(CStrRef v) { return toInt64(v.get());}
inline int64_t toInt64(const ArrayData *v) { return (v && !v->empty()) ? 1 : 0;}
@@ -118,7 +126,9 @@ inline double toDouble(short v) { return v;}
inline double toDouble(int v) { return v;}
inline double toDouble(int64_t v) { return v;}
inline double toDouble(double v) { return v;}
inline double toDouble(litstr v) { return StringData(v).toDouble();}
inline double toDouble(litstr v) {
return StringData(v, CopyString).toDouble();
}
inline double toDouble(const StringData *v) { return v? v->toDouble() : 0;}
inline double toDouble(CStrRef v) { return toDouble(v.get());}
inline double toDouble(const ArrayData *v) {
+5 -6
Ver Arquivo
@@ -137,7 +137,7 @@ String::String(double n) {
}
StringData* buildStringData(litstr s) {
return NEW(StringData)(s, AttachLiteral);
return NEW(StringData)(s, CopyString);
}
///////////////////////////////////////////////////////////////////////////////
@@ -284,7 +284,7 @@ char String::charAt(int pos) const {
String &String::operator=(litstr s) {
if (m_px) decRefStr(m_px);
if (s) {
m_px = NEW(StringData)(s, AttachLiteral);
m_px = NEW(StringData)(s, CopyString);
m_px->setRefCount(1);
} else {
m_px = nullptr;
@@ -320,7 +320,7 @@ String &String::operator=(CVarRef var) {
String &String::operator+=(litstr s) {
if (s && *s) {
if (empty()) {
m_px = NEW(StringData)(s, AttachLiteral);
m_px = NEW(StringData)(s, CopyString);
m_px->setRefCount(1);
} else if (m_px->getCount() == 1) {
m_px->append(s, strlen(s));
@@ -725,12 +725,11 @@ void String::dump() const {
// StaticString
StaticString::StaticString(litstr s) {
StackStringData sd(s);
m_px = StringData::GetStaticString(&sd);
m_px = StringData::GetStaticString(s);
}
StaticString::StaticString(litstr s, int length) {
StackStringData sd(s, length, AttachLiteral);
StackStringData sd(s, length, CopyString);
m_px = StringData::GetStaticString(&sd);
}
+5 -5
Ver Arquivo
@@ -77,7 +77,7 @@ static VarNR ToKey(CVarRef v) { return v.toKey(); }
Variant::Variant(litstr v) {
m_type = KindOfString;
m_data.pstr = NEW(StringData)(v);
m_data.pstr = NEW(StringData)(v, CopyString);
m_data.pstr->incRefCount();
}
@@ -293,7 +293,7 @@ HOT_FUNC IMPLEMENT_SET(int64_t, m_type = KindOfInt64; m_data.num = v)
IMPLEMENT_SET(double, m_type = KindOfDouble; m_data.dbl = v)
IMPLEMENT_SET(litstr,
m_type = KindOfString;
m_data.pstr = NEW(StringData)(v);
m_data.pstr = NEW(StringData)(v, CopyString);
m_data.pstr->incRefCount())
IMPLEMENT_SET(const StaticString&,
StringData* s = v.get();
@@ -1563,7 +1563,7 @@ bool Variant::same(double v2) const {
}
bool Variant::same(litstr v2) const {
StackStringData sd2(v2);
StackStringData sd2(v2, CopyString);
return same(&sd2);
}
@@ -3100,12 +3100,12 @@ void Variant::unserialize(VariableUnserializer *uns,
throw Exception("Mangled private object property");
}
}
String k(kdata + subLen, ksize - subLen, AttachLiteral);
String k(kdata + subLen, ksize - subLen, CopyString);
if (kdata[1] == '*') {
unserializeProp(uns, obj.get(), k, clsName, key, i + 1);
} else {
unserializeProp(uns, obj.get(), k,
String(kdata + 1, subLen - 2, AttachLiteral),
String(kdata + 1, subLen - 2, CopyString),
key, i + 1);
}
} else {
+2 -2
Ver Arquivo
@@ -69,7 +69,7 @@ void ThriftBuffer::write(CStrRef data) {
void ThriftBuffer::flush() {
*m_p = '\0';
String data(m_buf, m_p - m_buf, AttachLiteral);
String data(m_buf, m_p - m_buf, CopyString);
m_p = m_buf;
flushImpl(data);
}
@@ -210,7 +210,7 @@ void ThriftBuffer::read(std::string &data) {
}
void ThriftBuffer::write(const std::string &data) {
write(String(data.data(), data.size(), AttachLiteral));
write(String(data.data(), data.size(), CopyString));
}
void ThriftBuffer::read(std::vector<std::string> &data) {
+5 -5
Ver Arquivo
@@ -742,13 +742,13 @@ bool BreakPointInfo::MatchClass(const char *fcls, const std::string &bcls,
return Match(fcls, 0, bcls, true, true);
}
StackStringData sdBClsName(bcls.c_str());
StackStringData sdBClsName(bcls.c_str(), CopyString);
VM::Class* clsB = VM::Unit::lookupClass(&sdBClsName);
StackStringData sdFClsName(fcls);
StackStringData sdFClsName(fcls, CopyString);
VM::Class* clsF = VM::Unit::lookupClass(&sdFClsName);
if (!clsB) return false;
if (clsB == clsF) return true;
StackStringData sdFuncName(func);
StackStringData sdFuncName(func, CopyString);
VM::Func* f = clsB->lookupMethod(&sdFuncName);
if (!f) return false;
return (f->baseCls() == clsF);
@@ -773,8 +773,8 @@ bool BreakPointInfo::Match(const char *haystack, int haystack_len,
Variant matches;
Variant r = preg_match(String(needle.c_str(), needle.size(),
AttachLiteral),
String(haystack, haystack_len, AttachLiteral),
CopyString),
String(haystack, haystack_len, CopyString),
matches);
return r.same(1);
}
@@ -213,7 +213,7 @@ void CmdInstrument::validateAndWriteToTable(DebuggerProxy *proxy) {
(*tablePC)[(int64_t)pc] = inj;
}
if (ipi->m_locType == InstPointInfo::LocFuncEntry) {
StackStringData sd(ipi->m_func.c_str(), ipi->m_func.size(), AttachLiteral);
StackStringData sd(ipi->m_func.c_str(), ipi->m_func.size(), CopyString);
const StringData* sdCache = VM::InjectionCache::GetStringData(&sd);
if (tableFEntry == nullptr) {
tableFEntry = new VM::InjectionTableSD();
+4 -4
Ver Arquivo
@@ -1353,7 +1353,7 @@ void DebuggerClient::print(CStrRef msg) {
name(msg); \
} \
void DebuggerClient::name(const std::string &msg) { \
name(String(msg.data(), msg.length(), AttachLiteral)); \
name(String(msg.data(), msg.length(), CopyString)); \
} \
IMPLEMENT_COLOR_OUTPUT(help, stdout, HelpColor);
@@ -1366,7 +1366,7 @@ IMPLEMENT_COLOR_OUTPUT(error, stderr, ErrorColor);
string DebuggerClient::wrap(const std::string &s) {
TRACE(2, "DebuggerClient::wrap\n");
String ret = StringUtil::WordWrap(String(s.c_str(), s.size(), AttachLiteral),
String ret = StringUtil::WordWrap(String(s.c_str(), s.size(), CopyString),
LineWidth - 4, "\n", true);
return string(ret.data(), ret.size());
}
@@ -1411,8 +1411,8 @@ void DebuggerClient::helpCmds(const std::vector<const char *> &cmds) {
StringBuffer sb;
for (unsigned int i = 0; i < cmds.size() - 1; i += 2) {
String cmd(cmds[i], AttachLiteral);
String desc(cmds[i+1], AttachLiteral);
String cmd(cmds[i], CopyString);
String desc(cmds[i+1], CopyString);
// two special formats
if (cmd.empty() && desc.empty()) {
@@ -27,7 +27,7 @@ String DebuggerThriftBuffer::readImpl() {
assert(m_size <= BUFFER_SIZE);
int nread = m_socket->readImpl(m_buffer, m_size);
m_buffer[nread] = '\0';
return String(m_buffer, nread, AttachLiteral);
return String(m_buffer, nread, CopyString);
}
void DebuggerThriftBuffer::flushImpl(CStrRef data) {
+14 -14
Ver Arquivo
@@ -479,7 +479,7 @@ void const_load_impl(struct cache_info *info,
const char **p = objects;
for (int i = 0; i < count; i++, p += 4) {
String key(*p, (int)(int64_t)*(p+1), CopyString);
String value(*(p+2), (int)(int64_t)*(p+3), AttachLiteral);
String value(*(p+2), (int)(int64_t)*(p+3), CopyString);
const_load_set(key, unserialize_from_string(value));
}
}
@@ -491,7 +491,7 @@ void const_load_impl(struct cache_info *info,
const char **p = thrifts;
for (int i = 0; i < count; i++, p += 4) {
String key(*p, (int)(int64_t)*(p+1), CopyString);
String value(*(p+2), (int)(int64_t)*(p+3), AttachLiteral);
String value(*(p+2), (int)(int64_t)*(p+3), CopyString);
Variant success;
Variant v = f_fb_thrift_unserialize(value, ref(success));
if (same(success, false)) {
@@ -507,7 +507,7 @@ void const_load_impl(struct cache_info *info,
const char **p = others;
for (int i = 0; i < count; i++, p += 4) {
String key(*p, (int)(int64_t)*(p+1), CopyString);
String value(*(p+2), (int)(int64_t)*(p+3), AttachLiteral);
String value(*(p+2), (int)(int64_t)*(p+3), CopyString);
Variant v = unserialize_from_string(value);
if (same(v, false)) {
throw Exception("bad apc archive, unserialize_from_string failed");
@@ -574,7 +574,7 @@ void apc_load_impl(struct cache_info *info,
item.key = *p;
item.len = (int)(int64_t)*(p+1);
// Strings would be copied into APC anyway.
String value(*(p+2), (int)(int64_t)*(p+3), AttachLiteral);
String value(*(p+2), (int)(int64_t)*(p+3), CopyString);
value.checkStatic();
s.constructPrime(value, item, false);
}
@@ -590,7 +590,7 @@ void apc_load_impl(struct cache_info *info,
SharedStore::KeyValuePair &item = vars[i];
item.key = *p;
item.len = (int)(int64_t)*(p+1);
String value(*(p+2), (int)(int64_t)*(p+3), AttachLiteral);
String value(*(p+2), (int)(int64_t)*(p+3), CopyString);
s.constructPrime(value, item, true);
}
s.prime(vars);
@@ -605,7 +605,7 @@ void apc_load_impl(struct cache_info *info,
SharedStore::KeyValuePair &item = vars[i];
item.key = *p;
item.len = (int)(int64_t)*(p+1);
String value(*(p+2), (int)(int64_t)*(p+3), AttachLiteral);
String value(*(p+2), (int)(int64_t)*(p+3), CopyString);
Variant success;
Variant v = f_fb_thrift_unserialize(value, ref(success));
if (same(success, false)) {
@@ -626,7 +626,7 @@ void apc_load_impl(struct cache_info *info,
item.key = *p;
item.len = (int)(int64_t)*(p+1);
String value(*(p+2), (int)(int64_t)*(p+3), AttachLiteral);
String value(*(p+2), (int)(int64_t)*(p+3), CopyString);
Variant v = unserialize_from_string(value);
if (same(v, false)) {
// we can't possibly get here if it was a boolean "false" that's
@@ -727,7 +727,7 @@ void const_load_impl_compressed
for (int i = 0; i < count; i++) {
String key(p, object_lens[i + i + 2], CopyString);
p += object_lens[i + i + 2] + 1;
String value(p, object_lens[i + i + 3], AttachLiteral);
String value(p, object_lens[i + i + 3], CopyString);
const_load_set(key, unserialize_from_string(value));
p += object_lens[i + i + 3] + 1;
}
@@ -745,7 +745,7 @@ void const_load_impl_compressed
for (int i = 0; i < count; i++) {
String key(p, thrift_lens[i + i + 2], CopyString);
p += thrift_lens[i + i + 2] + 1;
String value(p, thrift_lens[i + i + 3], AttachLiteral);
String value(p, thrift_lens[i + i + 3], CopyString);
Variant success;
Variant v = f_fb_thrift_unserialize(value, ref(success));
if (same(success, false)) {
@@ -768,7 +768,7 @@ void const_load_impl_compressed
for (int i = 0; i < count; i++) {
String key(p, other_lens[i + i + 2], CopyString);
p += other_lens[i + i + 2] + 1;
String value(p, other_lens[i + i + 3], AttachLiteral);
String value(p, other_lens[i + i + 3], CopyString);
Variant v = unserialize_from_string(value);
if (same(v, false)) {
throw Exception("bad apc archive, unserialize_from_string failed");
@@ -857,7 +857,7 @@ void apc_load_impl_compressed
item.len = string_lens[i + i + 2];
p += string_lens[i + i + 2] + 1; // skip \0
// Strings would be copied into APC anyway.
String value(p, string_lens[i + i + 3], AttachLiteral);
String value(p, string_lens[i + i + 3], CopyString);
value.checkStatic();
s.constructPrime(value, item, false);
p += string_lens[i + i + 3] + 1; // skip \0
@@ -880,7 +880,7 @@ void apc_load_impl_compressed
item.key = p;
item.len = object_lens[i + i + 2];
p += object_lens[i + i + 2] + 1; // skip \0
String value(p, object_lens[i + i + 3], AttachLiteral);
String value(p, object_lens[i + i + 3], CopyString);
s.constructPrime(value, item, true);
p += object_lens[i + i + 3] + 1; // skip \0
}
@@ -902,7 +902,7 @@ void apc_load_impl_compressed
item.key = p;
item.len = thrift_lens[i + i + 2];
p += thrift_lens[i + i + 2] + 1; // skip \0
String value(p, thrift_lens[i + i + 3], AttachLiteral);
String value(p, thrift_lens[i + i + 3], CopyString);
Variant success;
Variant v = f_fb_thrift_unserialize(value, ref(success));
if (same(success, false)) {
@@ -929,7 +929,7 @@ void apc_load_impl_compressed
item.key = p;
item.len = other_lens[i + i + 2];
p += other_lens[i + i + 2] + 1; // skip \0
String value(p, other_lens[i + i + 3], AttachLiteral);
String value(p, other_lens[i + i + 3], CopyString);
Variant v = unserialize_from_string(value);
if (same(v, false)) {
// we can't possibly get here if it was a boolean "false" that's
+4 -4
Ver Arquivo
@@ -646,10 +646,10 @@ public:
switch (t->method) {
case PHP_CURL_STDOUT:
echo(String(data, length, AttachLiteral));
echo(String(data, length, CopyString));
break;
case PHP_CURL_FILE:
return t->fp->write(String(data, length, AttachLiteral), length);
return t->fp->write(String(data, length, CopyString), length);
case PHP_CURL_RETURN:
if (length > 0) {
t->buf.append(data, (int)length);
@@ -680,11 +680,11 @@ public:
if (ch->m_write.method == PHP_CURL_RETURN && length > 0) {
ch->m_write.buf.append(data, (int)length);
} else {
echo(String(data, length, AttachLiteral));
echo(String(data, length, CopyString));
}
break;
case PHP_CURL_FILE:
return t->fp->write(String(data, length, AttachLiteral), length);
return t->fp->write(String(data, length, CopyString), length);
case PHP_CURL_USER:
{
Variant ret = ch->do_callback(
+4 -4
Ver Arquivo
@@ -47,11 +47,11 @@ String f_intl_get_error_message() {
if (!s_intl_error->m_error.custom_error_message.empty()) {
return s_intl_error->m_error.custom_error_message;
}
return String(u_errorName(s_intl_error->m_error.code), AttachLiteral);
return String(u_errorName(s_intl_error->m_error.code), CopyString);
}
String f_intl_error_name(int64_t error_code) {
return String(u_errorName((UErrorCode)error_code), AttachLiteral);
return String(u_errorName((UErrorCode)error_code), CopyString);
}
bool f_intl_is_failure(int64_t error_code) {
@@ -222,7 +222,7 @@ int64_t c_Collator::t_geterrorcode() {
}
String c_Collator::t_geterrormessage() {
return String(u_errorName(m_errcode.code), AttachLiteral);
return String(u_errorName(m_errcode.code), CopyString);
}
String c_Collator::t_getlocale(int64_t type /* = 0 */) {
@@ -234,7 +234,7 @@ String c_Collator::t_getlocale(int64_t type /* = 0 */) {
String ret(
(char*)ucol_getLocaleByType(m_ucoll, (ULocDataLocaleType)type,
&(m_errcode.code)),
AttachLiteral);
CopyString);
if (U_FAILURE(m_errcode.code)) {
m_errcode.custom_error_message = "Error getting locale by type";
s_intl_error->m_error.code = m_errcode.code;
+4 -4
Ver Arquivo
@@ -2414,7 +2414,7 @@ int pdo_parse_params(PDOStatement *stmt, CStrRef in, String &out) {
if (query_type != PDO_PLACEHOLDER_POSITIONAL && bindno > params.size()) {
int ok = 1;
for (plc = placeholders; plc; plc = plc->next) {
if (!params.exists(String(plc->pos, plc->len, AttachLiteral))) {
if (!params.exists(String(plc->pos, plc->len, CopyString))) {
ok = 0;
break;
}
@@ -2442,7 +2442,7 @@ safe:
if (query_type == PDO_PLACEHOLDER_POSITIONAL) {
vparam = params[plc->bindno];
} else {
vparam = params[String(plc->pos, plc->len, AttachLiteral)];
vparam = params[String(plc->pos, plc->len, CopyString)];
}
if (vparam.isNull()) {
/* parameter was not defined */
@@ -2545,7 +2545,7 @@ rewrite:
for (plc = placeholders; plc; plc = plc->next) {
int skip_map = 0;
String name(plc->pos, plc->len, AttachLiteral);
String name(plc->pos, plc->len, CopyString);
/* check if bound parameter is already available */
if (!strcmp(name.c_str(), "?") ||
@@ -2577,7 +2577,7 @@ rewrite:
newbuffer_len = in.size();
for (plc = placeholders; plc; plc = plc->next) {
String name(plc->pos, plc->len, AttachLiteral);
String name(plc->pos, plc->len, CopyString);
stmt->bound_param_map.set(plc->bindno, name);
plc->quoted = "?";
}
+1 -1
Ver Arquivo
@@ -466,7 +466,7 @@ void f_passthru(CStrRef command, VRefParam return_var /* = null */) {
if (len == -1 && errno == EINTR) continue;
if (len <= 0) break; // break on error or EOF
buffer[len] = '\0';
echo(String(buffer, len, AttachLiteral));
echo(String(buffer, len, CopyString));
}
int ret = ctx.exit();
if (WIFEXITED(ret)) ret = WEXITSTATUS(ret);
+1 -1
Ver Arquivo
@@ -316,7 +316,7 @@ String SessionModule::create_sid() {
to_read : (int)sizeof(buf)));
if (n <= 0) break;
if (!f_hash_update(context,
String((const char *)rbuf, n, AttachLiteral))) {
String((const char *)rbuf, n, CopyString))) {
Logger::Error("hash_update() failed");
::close(fd);
return String();
+1 -1
Ver Arquivo
@@ -965,7 +965,7 @@ void c_SimpleXMLElement::t_offsetunset(CVarRef index) {
if (m_attributes.toArray().exists(name) && m_node) {
for (xmlAttrPtr attr = m_node->properties; attr; attr = attr->next) {
if (String((char*)attr->name, xmlStrlen(attr->name), AttachLiteral) ==
if (String((char*)attr->name, xmlStrlen(attr->name), CopyString) ==
name) {
xmlUnlinkNode((xmlNodePtr)attr);
break;
+8 -8
Ver Arquivo
@@ -476,9 +476,9 @@ static bool do_request(c_SoapClient *client, xmlDoc *request,
client->m_last_request = String((char*)buf, buf_size, CopyString);
}
response = client->o_invoke_few_args(s___dorequest, -1, 5,
String(buf, buf_size, AttachLiteral),
String(location, AttachLiteral),
String(action, AttachLiteral),
String(buf, buf_size, CopyString),
String(location, CopyString),
String(action, CopyString),
version, one_way);
if (!response.isString()) {
if (client->m_soap_fault.isNull()) {
@@ -1774,7 +1774,7 @@ static void send_soap_server_fault(sdlFunctionPtr function, Variant fault,
xmlChar *buf; int size;
xmlDocDumpMemory(doc_return, &buf, &size);
if (buf) {
echo(String((const char *)buf, size, AttachLiteral));
echo(String((const char *)buf, size, CopyString));
xmlFree(buf);
}
xmlFreeDoc(doc_return);
@@ -2087,16 +2087,16 @@ void c_SoapServer::t_handle(CStrRef request /* = null_string */) {
if (!data || !*data || !size) {
return;
}
req = String(data, size, AttachLiteral);
req = String(data, size, CopyString);
SystemGlobals *g = (SystemGlobals*)get_global_variables();
if (g->GV(_SERVER).toArray().exists(s_HTTP_CONTENT_ENCODING)) {
String encoding = g->GV(_SERVER)[s_HTTP_CONTENT_ENCODING];
Variant ret;
if (encoding == "gzip" || encoding == "x-gzip") {
ret = f_gzinflate(String(data, size, AttachLiteral));
ret = f_gzinflate(String(data, size, CopyString));
} else if (encoding == "deflate") {
ret = f_gzuncompress(String(data, size, AttachLiteral));
ret = f_gzuncompress(String(data, size, CopyString));
} else {
raise_warning("Request is encoded with unknown compression '%s'",
encoding.data());
@@ -2252,7 +2252,7 @@ void c_SoapServer::t_handle(CStrRef request /* = null_string */) {
}
output_xml_header(soap_version);
if (buf) {
echo(String((char*)buf, size, AttachLiteral));
echo(String((char*)buf, size, CopyString));
xmlFree(buf);
}
}
+1 -1
Ver Arquivo
@@ -105,7 +105,7 @@ Variant f_stream_copy_to_stream(CObjRef source, CObjRef dest,
if (rbytes == 0) break;
if (rbytes < 0) return false;
buf[rbytes] = '\0';
if (destFile->write(String(buf, rbytes, AttachLiteral)) != rbytes) {
if (destFile->write(String(buf, rbytes, CopyString)) != rbytes) {
return false;
}
cbytes += rbytes;
+1 -1
Ver Arquivo
@@ -145,7 +145,7 @@ static void url_encode_array(StringBuffer &ret, CVarRef varr,
new_prefix += key_suffix;
new_prefix += "%5B";
url_encode_array(ret, data, seen_arrs, String(),
new_prefix.detach(), String("%5D", AttachLiteral),
new_prefix.detach(), String("%5D", CopyString),
arg_sep);
} else {
if (!ret.empty()) {
+1 -1
Ver Arquivo
@@ -871,7 +871,7 @@ int64_t f_xml_get_error_code(CObjRef parser) {
String f_xml_error_string(int code) {
char * str = (char *)XML_ErrorString((XML_Error)/*(int)*/code);
return String(str, AttachLiteral);
return String(str, CopyString);
}
///////////////////////////////////////////////////////////////////////////////
+1 -1
Ver Arquivo
@@ -1130,7 +1130,7 @@ Variant parse_php_serialized(AsmState& as) {
// String wants a null, and dereferences one past the size we give
// it.
buffer.push_back('\0');
String data(&buffer[0], buffer.size() - 1, AttachLiteral);
String data(&buffer[0], buffer.size() - 1, CopyString);
return unserialize_from_string(data);
}
+2 -2
Ver Arquivo
@@ -112,8 +112,8 @@ const Injection* InjectionCache::getInjectionImpl(const StringData* code,
const Injection* InjectionCache::getInjectionImpl(const std::string& code,
const std::string& desc) {
StackStringData sdCode(code.c_str(), code.size(), AttachLiteral);
StackStringData sdDesc(desc.c_str(), desc.size(), AttachLiteral);
StackStringData sdCode(code.c_str(), code.size(), CopyString);
StackStringData sdDesc(desc.c_str(), desc.size(), CopyString);
return getInjectionImpl(&sdCode, &sdDesc);
}
+1 -1
Ver Arquivo
@@ -48,7 +48,7 @@ static inline void instHookSD(int type, const StringData* sd) {
}
static inline void instHookStr(int type, const char* str) {
StackStringData sd(str, AttachLiteral);
StackStringData sd(str, CopyString);
instHookSD(type, &sd);
}
+3 -2
Ver Arquivo
@@ -14,8 +14,9 @@
+----------------------------------------------------------------------+
*/
#include "runtime/vm/repo.h"
#include "runtime/vm/repo_helpers.h"
#include "runtime/vm/repo.h"
#include "runtime/vm/blob_helper.h"
#include "runtime/base/builtin_functions.h"
@@ -380,7 +381,7 @@ void RepoQuery::getStaticString(int iCol, StringData*& s) {
const char* text;
size_t size;
getText(iCol, text, size);
StackStringData sd(text, size, AttachLiteral);
StackStringData sd(text, size, CopyString);
s = StringData::GetStaticString(&sd);
}
}
+4 -3
Ver Arquivo
@@ -21,6 +21,7 @@
#include <sqlite3.h>
#include "runtime/base/md5.h"
#include "runtime/vm/core_types.h"
namespace HPHP {
namespace VM {
@@ -62,7 +63,7 @@ class RepoExc : public std::exception {
class RepoStmt {
public:
RepoStmt(Repo& repo);
explicit RepoStmt(Repo& repo);
~RepoStmt();
private:
void finalize();
@@ -84,7 +85,7 @@ class RepoStmt {
// queries outside of transactions are fraught with peril.
class RepoQuery {
public:
RepoQuery(RepoStmt& stmt)
explicit RepoQuery(RepoStmt& stmt)
: m_stmt(stmt), m_row(false), m_done(false) {
assert(m_stmt.prepared());
}
@@ -193,7 +194,7 @@ class RepoTxnQuery : public RepoQuery {
class RepoProxy {
public:
RepoProxy(Repo& repo) : m_repo(repo) {}
explicit RepoProxy(Repo& repo) : m_repo(repo) {}
~RepoProxy() {}
protected:
+1 -1
Ver Arquivo
@@ -4161,7 +4161,7 @@ void CodeGenerator::cgLdClsPropAddrCached(IRInstruction* inst) {
string sds(Util::toLower(clsNameString->data()) + ":" +
string(propNameString->data(), propNameString->size()));
StackStringData sd(sds.c_str(), sds.size(), AttachLiteral);
StackStringData sd(sds.c_str(), sds.size(), CopyString);
CacheHandle ch = SPropCache::alloc(&sd);
auto dstReg = dst->getReg();
+5 -14
Ver Arquivo
@@ -7766,7 +7766,7 @@ void TranslatorX64::emitStaticPropInlineLookup(const NormalizedInstruction& i,
const StringData* clsName = cls->preClass()->name();
string sds(Util::toLower(clsName->data()) + ":" +
string(propName->data(), propName->size()));
StackStringData sd(sds.c_str(), sds.size(), AttachLiteral);
StackStringData sd(sds.c_str(), sds.size(), CopyString);
ch = SPropCache::alloc(&sd);
SKTRACE(1, i.source, "SPropInlineLookup %s %d\n", sd.data(), int(ch));
@@ -8665,12 +8665,9 @@ TranslatorX64::translateFPushFunc(const Tracelet& t,
int startOfActRec = int(sizeof(Cell)) - int(sizeof(ActRec));
size_t funcOff = AROFF(m_func) + startOfActRec;
size_t thisOff = AROFF(m_this) + startOfActRec;
if (false) { // typecheck
StackStringData sd("foo");
const UNUSED Func* f = FuncCache::lookup(ch, &sd);
}
const Func* (*f)(CacheHandle, StringData*, const void*) = FuncCache::lookup;
SKTRACE(1, i.source, "ch %d\n", ch);
EMIT_CALL(a, FuncCache::lookup, IMM(ch), V(inLoc));
EMIT_CALL(a, f, IMM(ch), V(inLoc), IMM(0));
recordCall(i);
emitVStackStore(a, i, rax, funcOff, sz::qword);
emitVStackStoreImm(a, i, 0, thisOff, sz::qword, &m_regMap);
@@ -9449,14 +9446,8 @@ TranslatorX64::translateFPushFuncD(const Tracelet& t,
a.test_reg64_reg64(r(scratch), r(scratch));
{
UnlikelyIfBlock ifNull(CC_Z, a, astubs);
if (false) { // typecheck
StackStringData sd("foo");
FixedFuncCache::lookupUnknownFunc(&sd);
}
EMIT_CALL(astubs, TCA(FixedFuncCache::lookupUnknownFunc),
IMM(uintptr_t(name)));
const Func* (*func)(StringData*) = FixedFuncCache::lookupUnknownFunc;
EMIT_CALL(astubs, TCA(func), IMM(uintptr_t(name)));
recordReentrantStubCall(i);
emitMovRegReg(astubs, rax, r(scratch));
}
+1 -1
Ver Arquivo
@@ -202,7 +202,7 @@ bool TestCppBase::TestString() {
VS(String("test").rvalAt(2).c_str(), "s");
String s = "test";
s.lvalAt(2) = "";
VS(s, String("te\0t", 4, AttachLiteral));
VS(s, String("te\0t", 4, CopyString));
s.lvalAt(2) = "zz";
VS(s, "tezt");
s.lvalAt(5) = "q";
+2 -2
Ver Arquivo
@@ -213,7 +213,7 @@ bool TestExtFb::test_fb_utf8ize() {
}
{
// We intentionally consider null bytes invalid sequences.
Variant s = String("abc\0def", 7, AttachLiteral);
Variant s = String("abc\0def", 7, CopyString);
VERIFY(f_fb_utf8ize(ref(s)));
if (RuntimeOption::Utf8izeReplace) {
VS(s, "abc\uFFFD""def");
@@ -259,7 +259,7 @@ bool TestExtFb::test_fb_utf8_strlen() {
// byte then continues parsing.
RuntimeOption::Utf8izeReplace = (i == 0);
{
Variant s = String("abc\0def", 7, AttachLiteral);
Variant s = String("abc\0def", 7, CopyString);
VS(s.toString().size(), 7);
VS(f_fb_utf8_strlen(s), 7);
+1 -1
Ver Arquivo
@@ -373,7 +373,7 @@ bool TestExtIcu_ucsdet::test_utf16() {
"d\x00!\x00";
// Take off 1 byte for the NUL at the end of the char[].
String utf16Str(utf16, sizeof utf16 - 1, AttachLiteral);
String utf16Str(utf16, sizeof utf16 - 1, CopyString);
VERIFY(detect_and_convert_to_utf8(
utf16Str,
"\ufeffHello, world!") == true);
+4 -4
Ver Arquivo
@@ -213,10 +213,10 @@ bool TestExtMisc::test_unpack() {
// Also covered in TestCodeRun::TestExtMisc
String iFF = f_str_repeat("\xFF", sizeof(int));
String le32_FF("\xFF\x00\x00\x00", 4, AttachLiteral);
String be32_FF("\x00\x00\x00\xFF", 4, AttachLiteral);
String le16_FF("\xFF\x00", 2, AttachLiteral);
String be16_FF("\x00\xFF", 2, AttachLiteral);
String le32_FF("\xFF\x00\x00\x00", 4, CopyString);
String be32_FF("\x00\x00\x00\xFF", 4, CopyString);
String le16_FF("\xFF\x00", 2, CopyString);
String be16_FF("\x00\xFF", 2, CopyString);
uint32_t endian_check = 1;
bool le = ((char*)&endian_check)[0];
+1 -1
Ver Arquivo
@@ -299,7 +299,7 @@ bool TestExtProcess::test_proc_open() {
{
File *f = pipes[0].toObject().getTyped<File>();
VERIFY(f->valid());
String s("<?php print(getenv('some_option')); ?>", AttachLiteral);
String s("<?php print(getenv('some_option')); ?>", CopyString);
f->write(s);
f->close();
}
+4 -4
Ver Arquivo
@@ -133,7 +133,7 @@ bool TestExtString::test_stringdata() {
bool TestExtString::test_addcslashes() {
VS(f_addcslashes("ABCDEFGH\n", "A..D\n"), "\\A\\B\\C\\DEFGH\\n");
VS(f_addcslashes(String("\x00\x0D\n", 3, AttachLiteral), null_string),
VS(f_addcslashes(String("\x00\x0D\n", 3, CopyString), null_string),
"\\000\\r\\n");
return Count(true);
}
@@ -441,8 +441,8 @@ bool TestExtString::test_str_pad() {
VS(f_str_pad(input, 10, "-=", k_STR_PAD_LEFT), "-=-=-Alien");
VS(f_str_pad(input, 10, "_", k_STR_PAD_BOTH), "__Alien___");
VS(f_str_pad(input, 6 , "___"), "Alien_");
VS(f_str_pad(input, 6 , String("\0", 1, AttachLiteral)),
String("Alien\0", 6, AttachLiteral));
VS(f_str_pad(input, 6 , String("\0", 1, CopyString)),
String("Alien\0", 6, CopyString));
return Count(true);
}
@@ -517,7 +517,7 @@ bool TestExtString::test_htmlspecialchars() {
VS(f_bin2hex(f_htmlspecialchars("\xA0", k_ENT_COMPAT)), "a0");
VS(f_bin2hex(f_htmlspecialchars("\xc2\xA0", k_ENT_COMPAT, "")), "c2a0");
VS(f_bin2hex(f_htmlspecialchars("\xc2\xA0", k_ENT_COMPAT, "UTF-8")), "c2a0");
String zfoo = String("\0foo", 4, AttachLiteral);
String zfoo = String("\0foo", 4, CopyString);
VS(f_htmlspecialchars(zfoo, k_ENT_COMPAT), zfoo);
VS(f_fb_htmlspecialchars(zfoo, k_ENT_COMPAT), zfoo);
+2 -2
Ver Arquivo
@@ -45,7 +45,7 @@ bool TestExtUrl::test_base64_decode() {
VS(f_base64_decode("VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw=="),
"This is an encoded string");
VERIFY(same(f_base64_decode("BgAYdjk="),
String("\006\0\030v9", 5, AttachLiteral)));
String("\006\0\030v9", 5, CopyString)));
VERIFY(!same(f_base64_decode("dGVzdA=="),
f_base64_decode("dGVzdA==CORRUPT")));
return Count(true);
@@ -54,7 +54,7 @@ bool TestExtUrl::test_base64_decode() {
bool TestExtUrl::test_base64_encode() {
VS(f_base64_encode("This is an encoded string"),
"VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==");
VS(f_base64_encode(String("\006\0\030v9", 5, AttachLiteral)), "BgAYdjk=");
VS(f_base64_encode(String("\006\0\030v9", 5, CopyString)), "BgAYdjk=");
return Count(true);
}
+4 -2
Ver Arquivo
@@ -289,7 +289,9 @@ bool TestExtVariable::test_var_export() {
VS(f_var_export(s, true), cr);
}
{
Variant v = CREATE_MAP3(String("\0", 1, AttachLiteral),"null","","empty","0", "nul");
Variant v = CREATE_MAP3(String("\0", 1, CopyString), "null",
"", "empty",
"0", "nul");
VS(f_var_export(v, true),
"array (\n"
" '' . \"\\0\" . '' => 'null',\n"
@@ -374,7 +376,7 @@ bool TestExtVariable::test_unserialize() {
VS(obj.o_get("name"), "value");
}
{
Variant v = unserialize_from_string(String("O:8:\"stdClass\":1:{s:7:\"\0*\0name\";s:5:\"value\";}", 45, AttachLiteral));
Variant v = unserialize_from_string(String("O:8:\"stdClass\":1:{s:7:\"\0*\0name\";s:5:\"value\";}", 45, CopyString));
VERIFY(v.is(KindOfObject));
Object obj = v.toObject();
VS(obj->o_getClassName(), "stdClass");
+4 -4
Ver Arquivo
@@ -277,13 +277,13 @@ bool TestExtZlib::test_nzcompress() {
}
bool TestExtZlib::test_nzuncompress() {
String s("garbage stuff", AttachLiteral);
String s("garbage stuff", CopyString);
Variant v = f_nzuncompress(s);
if (v != Variant(false)) {
return Count(false);
}
String empty("", AttachLiteral);
String empty("", CopyString);
String c(f_nzcompress(empty).asStrRef());
String d(f_nzuncompress(c).asStrRef());
if (d != empty) {
@@ -307,13 +307,13 @@ bool TestExtZlib::test_lz4hccompress() {
bool TestExtZlib::test_lz4uncompress() {
// first test uncompressing invalid string
String s("invalid compressed string", AttachLiteral);
String s("invalid compressed string", CopyString);
Variant v = f_lz4uncompress(s);
if (v != Variant(false)) {
return Count(false);
}
// try uncompressing empty string
String empty("", AttachLiteral);
String empty("", CopyString);
v = f_lz4uncompress(empty);
if (v != Variant(false)) {
return Count(false);