summaryrefslogtreecommitdiff
path: root/core/fxcrt
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-04-07 16:58:00 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-04-10 16:33:54 +0000
commitec8ff7d258ef25f7e3193572aeef220ff86784f0 (patch)
tree1c72cae7e3b43908840c9a6881b239850933680b /core/fxcrt
parent84b596d64aab8f8c6dd6145e9c210b145fc5631a (diff)
downloadpdfium-ec8ff7d258ef25f7e3193572aeef220ff86784f0.tar.xz
Fix bytestring passing conventions, part 2.
Change pass by reference to const reference or pointer. Change-Id: Ic007f14e6569679a846980a96cc627eac4ecd5d6 Reviewed-on: https://pdfium-review.googlesource.com/3953 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fxcrt')
-rw-r--r--core/fxcrt/fx_ext.h4
-rw-r--r--core/fxcrt/fx_extension.cpp14
-rw-r--r--core/fxcrt/xml/cxml_element.cpp12
-rw-r--r--core/fxcrt/xml/cxml_element.h6
4 files changed, 17 insertions, 19 deletions
diff --git a/core/fxcrt/fx_ext.h b/core/fxcrt/fx_ext.h
index 7d42e90ce3..d7f21af9ff 100644
--- a/core/fxcrt/fx_ext.h
+++ b/core/fxcrt/fx_ext.h
@@ -98,9 +98,7 @@ struct FX_GUID {
uint8_t data4[8];
};
void FX_GUID_CreateV4(FX_GUID* pGUID);
-void FX_GUID_ToString(const FX_GUID* pGUID,
- CFX_ByteString& bsStr,
- bool bSeparator = true);
+CFX_ByteString FX_GUID_ToString(const FX_GUID* pGUID, bool bSeparator = true);
#endif // PDF_ENABLE_XFA
#endif // CORE_FXCRT_FX_EXT_H_
diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp
index f13922e2da..acdce048e0 100644
--- a/core/fxcrt/fx_extension.cpp
+++ b/core/fxcrt/fx_extension.cpp
@@ -638,24 +638,24 @@ void FX_Random_GenerateCrypto(uint32_t* pBuffer, int32_t iCount) {
#ifdef PDF_ENABLE_XFA
static const char gs_FX_pHexChars[] = "0123456789ABCDEF";
+
void FX_GUID_CreateV4(FX_GUID* pGUID) {
FX_Random_GenerateMT((uint32_t*)pGUID, 4);
uint8_t& b = ((uint8_t*)pGUID)[6];
b = (b & 0x0F) | 0x40;
}
-void FX_GUID_ToString(const FX_GUID* pGUID,
- CFX_ByteString& bsStr,
- bool bSeparator) {
+
+CFX_ByteString FX_GUID_ToString(const FX_GUID* pGUID, bool bSeparator) {
+ CFX_ByteString bsStr;
char* pBuf = bsStr.GetBuffer(40);
- uint8_t b;
for (int32_t i = 0; i < 16; i++) {
- b = ((const uint8_t*)pGUID)[i];
+ uint8_t b = reinterpret_cast<const uint8_t*>(pGUID)[i];
*pBuf++ = gs_FX_pHexChars[b >> 4];
*pBuf++ = gs_FX_pHexChars[b & 0x0F];
- if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9)) {
+ if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9))
*pBuf++ = L'-';
}
- }
bsStr.ReleaseBuffer(bSeparator ? 36 : 32);
+ return bsStr;
}
#endif // PDF_ENABLE_XFA
diff --git a/core/fxcrt/xml/cxml_element.cpp b/core/fxcrt/xml/cxml_element.cpp
index 20ad54e88c..17caebfa14 100644
--- a/core/fxcrt/xml/cxml_element.cpp
+++ b/core/fxcrt/xml/cxml_element.cpp
@@ -65,16 +65,16 @@ CFX_ByteString CXML_Element::GetNamespaceURI(
}
void CXML_Element::GetAttrByIndex(int index,
- CFX_ByteString& space,
- CFX_ByteString& name,
- CFX_WideString& value) const {
+ CFX_ByteString* space,
+ CFX_ByteString* name,
+ CFX_WideString* value) const {
if (index < 0 || index >= m_AttrMap.GetSize())
return;
CXML_AttrItem& item = m_AttrMap.GetAt(index);
- space = item.m_QSpaceName;
- name = item.m_AttrName;
- value = item.m_Value;
+ *space = item.m_QSpaceName;
+ *name = item.m_AttrName;
+ *value = item.m_Value;
}
bool CXML_Element::HasAttr(const CFX_ByteStringC& name) const {
diff --git a/core/fxcrt/xml/cxml_element.h b/core/fxcrt/xml/cxml_element.h
index 2e18e187b7..349deba2c8 100644
--- a/core/fxcrt/xml/cxml_element.h
+++ b/core/fxcrt/xml/cxml_element.h
@@ -31,9 +31,9 @@ class CXML_Element {
const CXML_Element* GetParent() const { return m_pParent; }
uint32_t CountAttrs() const { return m_AttrMap.GetSize(); }
void GetAttrByIndex(int index,
- CFX_ByteString& space,
- CFX_ByteString& name,
- CFX_WideString& value) const;
+ CFX_ByteString* space,
+ CFX_ByteString* name,
+ CFX_WideString* value) const;
bool HasAttr(const CFX_ByteStringC& qName) const;
bool GetAttrValue(const CFX_ByteStringC& name,
CFX_WideString& attribute) const;