summaryrefslogtreecommitdiff
path: root/core/fxcrt/string_data_template.h
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-09-27 10:53:11 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-09-27 16:11:38 +0000
commit875e98c581952478f3a3ccef9b2f2e3ed06c5346 (patch)
tree8e0d7e032056bf4c73d6da43c0f3ce4eadb74dfd /core/fxcrt/string_data_template.h
parentcc3a3ee3ebcc1baabdfa7ffca5876dbbfa3980c1 (diff)
downloadpdfium-875e98c581952478f3a3ccef9b2f2e3ed06c5346.tar.xz
Remove FX_STRSIZE and replace with size_t
BUG=pdfium:828 Change-Id: I5c40237433ebabaeabdb43aec9cdf783e41dfe16 Reviewed-on: https://pdfium-review.googlesource.com/13230 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core/fxcrt/string_data_template.h')
-rw-r--r--core/fxcrt/string_data_template.h26
1 files changed, 11 insertions, 15 deletions
diff --git a/core/fxcrt/string_data_template.h b/core/fxcrt/string_data_template.h
index afec50fe01..bc797c07e2 100644
--- a/core/fxcrt/string_data_template.h
+++ b/core/fxcrt/string_data_template.h
@@ -16,13 +16,13 @@ namespace fxcrt {
template <typename CharType>
class StringDataTemplate {
public:
- static StringDataTemplate* Create(FX_STRSIZE nLen) {
+ static StringDataTemplate* Create(size_t nLen) {
ASSERT(nLen > 0);
// Calculate space needed for the fixed portion of the struct plus the
// NUL char that is not included in |m_nAllocLength|.
int overhead = offsetof(StringDataTemplate, m_String) + sizeof(CharType);
- pdfium::base::CheckedNumeric<FX_STRSIZE> nSize = nLen;
+ pdfium::base::CheckedNumeric<size_t> nSize = nLen;
nSize *= sizeof(CharType);
nSize += overhead;
@@ -32,8 +32,8 @@ class StringDataTemplate {
// by using this otherwise wasted space.
nSize += 7;
nSize &= ~7;
- FX_STRSIZE totalSize = nSize.ValueOrDie();
- FX_STRSIZE usableLen = (totalSize - overhead) / sizeof(CharType);
+ size_t totalSize = nSize.ValueOrDie();
+ size_t usableLen = (totalSize - overhead) / sizeof(CharType);
ASSERT(usableLen >= nLen);
void* pData = pdfium::base::PartitionAllocGeneric(
@@ -47,7 +47,7 @@ class StringDataTemplate {
return result;
}
- static StringDataTemplate* Create(const CharType* pStr, FX_STRSIZE nLen) {
+ static StringDataTemplate* Create(const CharType* pStr, size_t nLen) {
StringDataTemplate* result = Create(nLen);
result->CopyContents(pStr, nLen);
return result;
@@ -60,7 +60,7 @@ class StringDataTemplate {
this);
}
- bool CanOperateInPlace(FX_STRSIZE nTotalLen) const {
+ bool CanOperateInPlace(size_t nTotalLen) const {
return m_nRefs <= 1 && nTotalLen <= m_nAllocLength;
}
@@ -70,15 +70,13 @@ class StringDataTemplate {
(other.m_nDataLength + 1) * sizeof(CharType));
}
- void CopyContents(const CharType* pStr, FX_STRSIZE nLen) {
+ void CopyContents(const CharType* pStr, size_t nLen) {
ASSERT(nLen >= 0 && nLen <= m_nAllocLength);
memcpy(m_String, pStr, nLen * sizeof(CharType));
m_String[nLen] = 0;
}
- void CopyContentsAt(FX_STRSIZE offset,
- const CharType* pStr,
- FX_STRSIZE nLen) {
+ void CopyContentsAt(size_t offset, const CharType* pStr, size_t nLen) {
ASSERT(offset >= 0 && nLen >= 0 && offset + nLen <= m_nAllocLength);
memcpy(m_String + offset, pStr, nLen * sizeof(CharType));
m_String[offset + nLen] = 0;
@@ -91,19 +89,17 @@ class StringDataTemplate {
// the address space itself is a good upper bound on it.
intptr_t m_nRefs;
- // |FX_STRSIZE| is currently typedef'd as |int|.
- // TODO(palmer): It should be a |size_t|, or at least unsigned.
// These lengths are in terms of number of characters, not bytes, and do not
// include the terminating NUL character, but the underlying buffer is sized
// to be capable of holding it.
- FX_STRSIZE m_nDataLength;
- FX_STRSIZE m_nAllocLength;
+ size_t m_nDataLength;
+ size_t m_nAllocLength;
// Not really 1, variable size.
CharType m_String[1];
private:
- StringDataTemplate(FX_STRSIZE dataLen, FX_STRSIZE allocLen)
+ StringDataTemplate(size_t dataLen, size_t allocLen)
: m_nRefs(0), m_nDataLength(dataLen), m_nAllocLength(allocLen) {
ASSERT(dataLen >= 0);
ASSERT(dataLen <= allocLen);