From b9812e548a3d1b8d6a6b2013cd1d9a7abec7b8d5 Mon Sep 17 00:00:00 2001 From: Edwin Smith Date: Mon, 22 Jul 2013 16:58:40 -0700 Subject: [PATCH] Change AttachLiteral to CopyString everywhere This is a big codemod but has no effect; the actual change was from D894412. --- hphp/compiler/option.cpp | 4 +-- hphp/runtime/base/concurrent_shared_store.cpp | 4 +-- hphp/runtime/base/program_functions.cpp | 2 +- hphp/runtime/base/runtime_option.cpp | 4 +-- hphp/runtime/base/shared_variant.cpp | 4 +-- hphp/runtime/base/string_data.cpp | 4 +-- hphp/runtime/base/string_data.h | 6 ++-- hphp/runtime/base/string_util.cpp | 2 +- hphp/runtime/base/thrift_buffer.cpp | 4 +-- hphp/runtime/base/timezone.cpp | 4 +-- hphp/runtime/base/type_string.cpp | 8 +++--- hphp/runtime/base/type_variant.cpp | 4 +-- hphp/runtime/debugger/break_point.cpp | 4 +-- hphp/runtime/debugger/debugger_client.cpp | 8 +++--- .../debugger/debugger_thrift_buffer.cpp | 2 +- hphp/runtime/ext/ext_apc.cpp | 28 +++++++++---------- hphp/runtime/ext/ext_curl.cpp | 4 +-- hphp/runtime/ext/ext_intl.cpp | 8 +++--- hphp/runtime/ext/ext_pdo.cpp | 8 +++--- hphp/runtime/ext/ext_process.cpp | 2 +- hphp/runtime/ext/ext_session.cpp | 2 +- hphp/runtime/ext/ext_simplexml.cpp | 2 +- hphp/runtime/ext/ext_soap.cpp | 16 +++++------ hphp/runtime/ext/ext_stream.cpp | 2 +- hphp/runtime/ext/ext_url.cpp | 2 +- hphp/runtime/ext/ext_xml.cpp | 2 +- hphp/runtime/server/files_match.cpp | 4 +-- hphp/runtime/server/http_protocol.cpp | 2 +- hphp/runtime/server/http_request_handler.cpp | 4 +-- hphp/runtime/server/rpc_request_handler.cpp | 2 +- hphp/runtime/server/satellite_server.cpp | 8 +++--- hphp/runtime/server/server_stats.cpp | 4 +-- hphp/runtime/server/source_root_info.cpp | 2 +- hphp/runtime/server/transport.cpp | 4 +-- hphp/runtime/server/virtual_host.cpp | 18 ++++++------ hphp/runtime/vm/jit/code-gen.cpp | 2 +- hphp/runtime/vm/repo_helpers.cpp | 2 +- hphp/test/ext/test_cpp_base.cpp | 2 +- 38 files changed, 96 insertions(+), 98 deletions(-) diff --git a/hphp/compiler/option.cpp b/hphp/compiler/option.cpp index 94491db4e..573e920b2 100644 --- a/hphp/compiler/option.cpp +++ b/hphp/compiler/option.cpp @@ -387,13 +387,13 @@ std::string Option::MangleFilename(const std::string &name, bool id) { bool Option::IsFileExcluded(const std::string &file, const std::set &patterns) { - String sfile(file.c_str(), file.size(), AttachLiteral); + String sfile(file.c_str(), file.size(), CopyString); for (set::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; } diff --git a/hphp/runtime/base/concurrent_shared_store.cpp b/hphp/runtime/base/concurrent_shared_store.cpp index 0fd53558d..cf98c6972 100644 --- a/hphp/runtime/base/concurrent_shared_store.cpp +++ b/hphp/runtime/base/concurrent_shared_store.cpp @@ -326,7 +326,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(); @@ -605,7 +605,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 { diff --git a/hphp/runtime/base/program_functions.cpp b/hphp/runtime/base/program_functions.cpp index e86be5f4e..69236dee6 100644 --- a/hphp/runtime/base/program_functions.cpp +++ b/hphp/runtime/base/program_functions.cpp @@ -502,7 +502,7 @@ void execute_command_line_begin(int argc, char **argv, int xhprof) { } String file = empty_string; if (argc > 0) { - file = NEW(StringData)(argv[0], AttachLiteral); + file = NEW(StringData)(argv[0], CopyString); } server.set(s_REQUEST_START_TIME, now); server.set(s_REQUEST_TIME, now); diff --git a/hphp/runtime/base/runtime_option.cpp b/hphp/runtime/base/runtime_option.cpp index c51bfa337..8190606e3 100644 --- a/hphp/runtime/base/runtime_option.cpp +++ b/hphp/runtime/base/runtime_option.cpp @@ -522,9 +522,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; } diff --git a/hphp/runtime/base/shared_variant.cpp b/hphp/runtime/base/shared_variant.cpp index 756743d24..b1cd0ad2f 100644 --- a/hphp/runtime/base/shared_variant.cpp +++ b/hphp/runtime/base/shared_variant.cpp @@ -153,7 +153,7 @@ Variant SharedVariant::toLocal() { { if (getSerializedArray()) { return apc_unserialize(String(m_data.str->data(), m_data.str->size(), - AttachLiteral)); + CopyString)); } return NEW(SharedMap)(this); } @@ -169,7 +169,7 @@ Variant SharedVariant::toLocal() { return m_data.obj->getObject(); } return apc_unserialize(String(m_data.str->data(), m_data.str->size(), - AttachLiteral)); + CopyString)); } } } diff --git a/hphp/runtime/base/string_data.cpp b/hphp/runtime/base/string_data.cpp index c9caf1b92..496db0706 100644 --- a/hphp/runtime/base/string_data.cpp +++ b/hphp/runtime/base/string_data.cpp @@ -138,7 +138,7 @@ StringData* StringData::GetStaticString(const String& str) { } StringData *StringData::GetStaticString(const char *str, size_t len) { - StackStringData sd(str, len, AttachLiteral); + StackStringData sd(str, len, CopyString); return GetStaticString(&sd); } @@ -600,7 +600,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; diff --git a/hphp/runtime/base/string_data.h b/hphp/runtime/base/string_data.h index facdd2658..9dc72c050 100644 --- a/hphp/runtime/base/string_data.h +++ b/hphp/runtime/base/string_data.h @@ -51,15 +51,13 @@ struct Slice { typedef Slice StringSlice; typedef Slice MutableSlice; -// Aggressively copy small strings and free the passed-in buffer immediately; -// otherwise keep the buffer for long strings, and free it when the string -// is mutated or released. +// Copy the passed-in string and free the buffer immediately. 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 }; +enum CopyStringMode { CopyString }; // reserve space for buffer that will be filled in by client. enum ReserveStringMode { ReserveString }; diff --git a/hphp/runtime/base/string_util.cpp b/hphp/runtime/base/string_util.cpp index ee1c451bd..c55af0e68 100644 --- a/hphp/runtime/base/string_util.cpp +++ b/hphp/runtime/base/string_util.cpp @@ -305,7 +305,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(); diff --git a/hphp/runtime/base/thrift_buffer.cpp b/hphp/runtime/base/thrift_buffer.cpp index f10ee51d3..fb66d08b1 100644 --- a/hphp/runtime/base/thrift_buffer.cpp +++ b/hphp/runtime/base/thrift_buffer.cpp @@ -70,7 +70,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); } @@ -211,7 +211,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 &data) { diff --git a/hphp/runtime/base/timezone.cpp b/hphp/runtime/base/timezone.cpp index edea62291..5774ebaca 100644 --- a/hphp/runtime/base/timezone.cpp +++ b/hphp/runtime/base/timezone.cpp @@ -157,7 +157,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; } @@ -183,7 +183,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()); } diff --git a/hphp/runtime/base/type_string.cpp b/hphp/runtime/base/type_string.cpp index ecf99e8b1..8cffd4af4 100644 --- a/hphp/runtime/base/type_string.cpp +++ b/hphp/runtime/base/type_string.cpp @@ -137,7 +137,7 @@ String::String(double n) { } StringData* buildStringData(litstr s) { - return NEW(StringData)(s, AttachLiteral); + return NEW(StringData)(s, CopyString); } /////////////////////////////////////////////////////////////////////////////// @@ -272,7 +272,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; @@ -308,7 +308,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)); @@ -610,7 +610,7 @@ StaticString::StaticString(litstr s) { } StaticString::StaticString(litstr s, int length) { - StackStringData sd(s, length, AttachLiteral); + StackStringData sd(s, length, CopyString); m_px = StringData::GetStaticString(&sd); } diff --git a/hphp/runtime/base/type_variant.cpp b/hphp/runtime/base/type_variant.cpp index f0b871197..71c4bf4aa 100644 --- a/hphp/runtime/base/type_variant.cpp +++ b/hphp/runtime/base/type_variant.cpp @@ -1841,12 +1841,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 { diff --git a/hphp/runtime/debugger/break_point.cpp b/hphp/runtime/debugger/break_point.cpp index bb09bd1dc..e56f49245 100644 --- a/hphp/runtime/debugger/break_point.cpp +++ b/hphp/runtime/debugger/break_point.cpp @@ -972,8 +972,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 HPHP::same(r, 1); } diff --git a/hphp/runtime/debugger/debugger_client.cpp b/hphp/runtime/debugger/debugger_client.cpp index 0720cbfda..5dfdc19a3 100644 --- a/hphp/runtime/debugger/debugger_client.cpp +++ b/hphp/runtime/debugger/debugger_client.cpp @@ -1438,7 +1438,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); @@ -1451,7 +1451,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()); } @@ -1496,8 +1496,8 @@ void DebuggerClient::helpCmds(const std::vector &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()) { diff --git a/hphp/runtime/debugger/debugger_thrift_buffer.cpp b/hphp/runtime/debugger/debugger_thrift_buffer.cpp index 5e12efc00..123791069 100644 --- a/hphp/runtime/debugger/debugger_thrift_buffer.cpp +++ b/hphp/runtime/debugger/debugger_thrift_buffer.cpp @@ -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) { diff --git a/hphp/runtime/ext/ext_apc.cpp b/hphp/runtime/ext/ext_apc.cpp index 99f65917e..e7c718c68 100644 --- a/hphp/runtime/ext/ext_apc.cpp +++ b/hphp/runtime/ext/ext_apc.cpp @@ -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_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); s.constructPrime(value, item, false); } s.prime(vars); @@ -589,7 +589,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); @@ -604,7 +604,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_unserialize(value, ref(success)); if (same(success, false)) { @@ -625,7 +625,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 @@ -726,7 +726,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; } @@ -744,7 +744,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_unserialize(value, ref(success)); if (same(success, false)) { @@ -767,7 +767,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"); @@ -856,7 +856,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); // todo: t2539893: check if value is already a static string s.constructPrime(value, item, false); p += string_lens[i + i + 3] + 1; // skip \0 @@ -879,7 +879,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 } @@ -901,7 +901,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_unserialize(value, ref(success)); if (same(success, false)) { @@ -928,7 +928,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 diff --git a/hphp/runtime/ext/ext_curl.cpp b/hphp/runtime/ext/ext_curl.cpp index 98093e374..ce913b801 100644 --- a/hphp/runtime/ext/ext_curl.cpp +++ b/hphp/runtime/ext/ext_curl.cpp @@ -649,7 +649,7 @@ public: g_context->write(data, length); 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); @@ -684,7 +684,7 @@ public: } 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( diff --git a/hphp/runtime/ext/ext_intl.cpp b/hphp/runtime/ext/ext_intl.cpp index 676ff1478..28addeee2 100644 --- a/hphp/runtime/ext/ext_intl.cpp +++ b/hphp/runtime/ext/ext_intl.cpp @@ -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; diff --git a/hphp/runtime/ext/ext_pdo.cpp b/hphp/runtime/ext/ext_pdo.cpp index 825e669ec..32adc6f6a 100644 --- a/hphp/runtime/ext/ext_pdo.cpp +++ b/hphp/runtime/ext/ext_pdo.cpp @@ -2418,7 +2418,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; } @@ -2446,7 +2446,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 */ @@ -2549,7 +2549,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(), "?") || @@ -2581,7 +2581,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 = "?"; } diff --git a/hphp/runtime/ext/ext_process.cpp b/hphp/runtime/ext/ext_process.cpp index a6ab77f9f..fc671e973 100644 --- a/hphp/runtime/ext/ext_process.cpp +++ b/hphp/runtime/ext/ext_process.cpp @@ -469,7 +469,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); diff --git a/hphp/runtime/ext/ext_session.cpp b/hphp/runtime/ext/ext_session.cpp index 4d66e41c1..38061b732 100644 --- a/hphp/runtime/ext/ext_session.cpp +++ b/hphp/runtime/ext/ext_session.cpp @@ -276,7 +276,7 @@ String SessionModule::create_sid() { to_read : (int)sizeof(buf))); if (n <= 0) break; if (!f_hash_update(context.toResource(), - String((const char *)rbuf, n, AttachLiteral))) { + String((const char *)rbuf, n, CopyString))) { Logger::Error("hash_update() failed"); ::close(fd); return String(); diff --git a/hphp/runtime/ext/ext_simplexml.cpp b/hphp/runtime/ext/ext_simplexml.cpp index c03a5d7c2..32fabccef 100644 --- a/hphp/runtime/ext/ext_simplexml.cpp +++ b/hphp/runtime/ext/ext_simplexml.cpp @@ -1001,7 +1001,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; diff --git a/hphp/runtime/ext/ext_soap.cpp b/hphp/runtime/ext/ext_soap.cpp index 49088a591..b1a5d33eb 100644 --- a/hphp/runtime/ext/ext_soap.cpp +++ b/hphp/runtime/ext/ext_soap.cpp @@ -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, 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()) { @@ -1777,7 +1777,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); @@ -2090,16 +2090,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); GlobalVariables *g = get_global_variables(); if (g->get(s__SERVER).toArray().exists(s_HTTP_CONTENT_ENCODING)) { String encoding = g->get(s__SERVER)[s_HTTP_CONTENT_ENCODING].toString(); 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()); @@ -2255,7 +2255,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); } } diff --git a/hphp/runtime/ext/ext_stream.cpp b/hphp/runtime/ext/ext_stream.cpp index 5dad5ad59..c4c1b78e3 100644 --- a/hphp/runtime/ext/ext_stream.cpp +++ b/hphp/runtime/ext/ext_stream.cpp @@ -105,7 +105,7 @@ Variant f_stream_copy_to_stream(CResRef source, CResRef 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; diff --git a/hphp/runtime/ext/ext_url.cpp b/hphp/runtime/ext/ext_url.cpp index 895ef37ad..0ac782f1f 100644 --- a/hphp/runtime/ext/ext_url.cpp +++ b/hphp/runtime/ext/ext_url.cpp @@ -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()) { diff --git a/hphp/runtime/ext/ext_xml.cpp b/hphp/runtime/ext/ext_xml.cpp index c4a44dd23..5c49e7afb 100644 --- a/hphp/runtime/ext/ext_xml.cpp +++ b/hphp/runtime/ext/ext_xml.cpp @@ -875,7 +875,7 @@ int64_t f_xml_get_error_code(CResRef 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); } /////////////////////////////////////////////////////////////////////////////// diff --git a/hphp/runtime/server/files_match.cpp b/hphp/runtime/server/files_match.cpp index 725542cc0..75bc245b5 100644 --- a/hphp/runtime/server/files_match.cpp +++ b/hphp/runtime/server/files_match.cpp @@ -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; diff --git a/hphp/runtime/server/http_protocol.cpp b/hphp/runtime/server/http_protocol.cpp index fce57ea59..d14696856 100644 --- a/hphp/runtime/server/http_protocol.cpp +++ b/hphp/runtime/server/http_protocol.cpp @@ -230,7 +230,7 @@ void HttpProtocol::PrepareSystemVariables(Transport *transport, // For literal we disregard RuntimeOption::AlwaysPopulateRawPostData if (uint32_t(size) <= StringData::MaxSize) { g->getRef(s_HTTP_RAW_POST_DATA) = - String((char*)data, size, AttachLiteral); + String((char*)data, size, CopyString); } } } diff --git a/hphp/runtime/server/http_request_handler.cpp b/hphp/runtime/server/http_request_handler.cpp index 123aa01c7..40a52afef 100644 --- a/hphp/runtime/server/http_request_handler.cpp +++ b/hphp/runtime/server/http_request_handler.cpp @@ -421,10 +421,10 @@ bool HttpRequestHandler::handleProxyRequest(Transport *transport, bool force) { bool HttpRequestHandler::MatchAnyPattern (const std::string &path, const std::vector &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; } diff --git a/hphp/runtime/server/rpc_request_handler.cpp b/hphp/runtime/server/rpc_request_handler.cpp index 8019027c4..094419b66 100644 --- a/hphp/runtime/server/rpc_request_handler.cpp +++ b/hphp/runtime/server/rpc_request_handler.cpp @@ -226,7 +226,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)); } } } diff --git a/hphp/runtime/server/satellite_server.cpp b/hphp/runtime/server/satellite_server.cpp index 37697a8a5..b405ada75 100644 --- a/hphp/runtime/server/satellite_server.cpp +++ b/hphp/runtime/server/satellite_server.cpp @@ -70,12 +70,12 @@ SatelliteServerInfo::SatelliteServerInfo(Hdf hdf) { } bool SatelliteServerInfo::checkMainURL(const std::string& path) { - String url(path.c_str(), path.size(), AttachLiteral); + String url(path.c_str(), path.size(), CopyString); for (std::set::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; } @@ -109,10 +109,10 @@ public: private: bool checkURL(const std::string &path) const { - String url(path.c_str(), path.size(), AttachLiteral); + String url(path.c_str(), path.size(), CopyString); for (const auto &allowed : m_allowedURLs) { Variant ret = preg_match - (String(allowed.c_str(), allowed.size(), AttachLiteral), url); + (String(allowed.c_str(), allowed.size(), CopyString), url); if (ret.toInt64() > 0) { return true; } diff --git a/hphp/runtime/server/server_stats.cpp b/hphp/runtime/server/server_stats.cpp index 2a906374e..24519653c 100644 --- a/hphp/runtime/server/server_stats.cpp +++ b/hphp/runtime/server/server_stats.cpp @@ -160,8 +160,8 @@ void ServerStats::Filter(list &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; } diff --git a/hphp/runtime/server/source_root_info.cpp b/hphp/runtime/server/source_root_info.cpp index c2ca34a1f..16a47b6b7 100644 --- a/hphp/runtime/server/source_root_info.cpp +++ b/hphp/runtime/server/source_root_info.cpp @@ -39,7 +39,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 (!same(r, 1)) { m_sandboxCond = SandboxCondition::Off; return; diff --git a/hphp/runtime/server/transport.cpp b/hphp/runtime/server/transport.cpp index e1f6e102f..0c778b4e0 100644 --- a/hphp/runtime/server/transport.cpp +++ b/hphp/runtime/server/transport.cpp @@ -690,7 +690,7 @@ void Transport::prepareHeaders(bool compressed, bool chunked, 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); @@ -783,7 +783,7 @@ void Transport::sendRawLocked(void *data, int size, int code /* = 200 */, // HTTP header handling if (!m_headerSent) { - String orig_response((const char *)data, size, AttachLiteral); + String orig_response((const char *)data, size, CopyString); prepareHeaders(compressed, chunked, response, orig_response); m_headerSent = true; } diff --git a/hphp/runtime/server/virtual_host.cpp b/hphp/runtime/server/virtual_host.cpp index 6484863db..37bc52043 100644 --- a/hphp/runtime/server/virtual_host.cpp +++ b/hphp/runtime/server/virtual_host.cpp @@ -261,9 +261,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; @@ -302,7 +302,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 (!same(ret, 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(); } diff --git a/hphp/runtime/vm/jit/code-gen.cpp b/hphp/runtime/vm/jit/code-gen.cpp index 58d8f0f24..56e2e0766 100755 --- a/hphp/runtime/vm/jit/code-gen.cpp +++ b/hphp/runtime/vm/jit/code-gen.cpp @@ -4832,7 +4832,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 = m_regs[dst].reg(); diff --git a/hphp/runtime/vm/repo_helpers.cpp b/hphp/runtime/vm/repo_helpers.cpp index 6d81558d1..80491b1f0 100644 --- a/hphp/runtime/vm/repo_helpers.cpp +++ b/hphp/runtime/vm/repo_helpers.cpp @@ -379,7 +379,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); } } diff --git a/hphp/test/ext/test_cpp_base.cpp b/hphp/test/ext/test_cpp_base.cpp index d8fb93f63..9091d9574 100644 --- a/hphp/test/ext/test_cpp_base.cpp +++ b/hphp/test/ext/test_cpp_base.cpp @@ -192,7 +192,7 @@ bool TestCppBase::TestString() { VS(String("test").rvalAt(2).c_str(), "s"); String s = "test"; s.set(2, String("")); - VS(s, String("te\0t", 4, AttachLiteral)); + VS(s, String("te\0t", 4, CopyString)); s.set(2, String("zz")); VS(s, "tezt"); s.set(5, String("q"));