Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: core/src/fxcrt/fx_basic_buffer.cpp

Issue 1512763013: Get rid of most instance of 'foo != NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: nits Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fxcrt/fx_basic_bstring.cpp ('k') | core/src/fxcrt/fx_basic_list.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/include/fxcrt/fx_basic.h" 7 #include "core/include/fxcrt/fx_basic.h"
8 8
9 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf); 9 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf);
10 CFX_BinaryBuf::CFX_BinaryBuf() 10 CFX_BinaryBuf::CFX_BinaryBuf()
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 AppendBlock(buf.m_pBuffer, buf.m_DataSize); 144 AppendBlock(buf.m_pBuffer, buf.m_DataSize);
145 return *this; 145 return *this;
146 } 146 }
147 void CFX_ByteTextBuf::operator=(const CFX_ByteStringC& str) { 147 void CFX_ByteTextBuf::operator=(const CFX_ByteStringC& str) {
148 CopyData(str.GetPtr(), str.GetLength()); 148 CopyData(str.GetPtr(), str.GetLength());
149 } 149 }
150 void CFX_WideTextBuf::AppendChar(FX_WCHAR ch) { 150 void CFX_WideTextBuf::AppendChar(FX_WCHAR ch) {
151 if (m_AllocSize < m_DataSize + (FX_STRSIZE)sizeof(FX_WCHAR)) { 151 if (m_AllocSize < m_DataSize + (FX_STRSIZE)sizeof(FX_WCHAR)) {
152 ExpandBuf(sizeof(FX_WCHAR)); 152 ExpandBuf(sizeof(FX_WCHAR));
153 } 153 }
154 ASSERT(m_pBuffer != NULL); 154 ASSERT(m_pBuffer);
155 *(FX_WCHAR*)(m_pBuffer + m_DataSize) = ch; 155 *(FX_WCHAR*)(m_pBuffer + m_DataSize) = ch;
156 m_DataSize += sizeof(FX_WCHAR); 156 m_DataSize += sizeof(FX_WCHAR);
157 } 157 }
158 CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const CFX_WideStringC& str) { 158 CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const CFX_WideStringC& str) {
159 AppendBlock(str.GetPtr(), str.GetLength() * sizeof(FX_WCHAR)); 159 AppendBlock(str.GetPtr(), str.GetLength() * sizeof(FX_WCHAR));
160 return *this; 160 return *this;
161 } 161 }
162 CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const CFX_WideString& str) { 162 CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const CFX_WideString& str) {
163 AppendBlock(str.c_str(), str.GetLength() * sizeof(FX_WCHAR)); 163 AppendBlock(str.c_str(), str.GetLength() * sizeof(FX_WCHAR));
164 return *this; 164 return *this;
165 } 165 }
166 CFX_WideTextBuf& CFX_WideTextBuf::operator<<(int i) { 166 CFX_WideTextBuf& CFX_WideTextBuf::operator<<(int i) {
167 char buf[32]; 167 char buf[32];
168 FXSYS_itoa(i, buf, 10); 168 FXSYS_itoa(i, buf, 10);
169 FX_STRSIZE len = FXSYS_strlen(buf); 169 FX_STRSIZE len = FXSYS_strlen(buf);
170 if (m_AllocSize < m_DataSize + (FX_STRSIZE)(len * sizeof(FX_WCHAR))) { 170 if (m_AllocSize < m_DataSize + (FX_STRSIZE)(len * sizeof(FX_WCHAR))) {
171 ExpandBuf(len * sizeof(FX_WCHAR)); 171 ExpandBuf(len * sizeof(FX_WCHAR));
172 } 172 }
173 ASSERT(m_pBuffer != NULL); 173 ASSERT(m_pBuffer);
174 FX_WCHAR* str = (FX_WCHAR*)(m_pBuffer + m_DataSize); 174 FX_WCHAR* str = (FX_WCHAR*)(m_pBuffer + m_DataSize);
175 for (FX_STRSIZE j = 0; j < len; j++) { 175 for (FX_STRSIZE j = 0; j < len; j++) {
176 *str++ = buf[j]; 176 *str++ = buf[j];
177 } 177 }
178 m_DataSize += len * sizeof(FX_WCHAR); 178 m_DataSize += len * sizeof(FX_WCHAR);
179 return *this; 179 return *this;
180 } 180 }
181 CFX_WideTextBuf& CFX_WideTextBuf::operator<<(double f) { 181 CFX_WideTextBuf& CFX_WideTextBuf::operator<<(double f) {
182 char buf[32]; 182 char buf[32];
183 FX_STRSIZE len = FX_ftoa((FX_FLOAT)f, buf); 183 FX_STRSIZE len = FX_ftoa((FX_FLOAT)f, buf);
184 if (m_AllocSize < m_DataSize + (FX_STRSIZE)(len * sizeof(FX_WCHAR))) { 184 if (m_AllocSize < m_DataSize + (FX_STRSIZE)(len * sizeof(FX_WCHAR))) {
185 ExpandBuf(len * sizeof(FX_WCHAR)); 185 ExpandBuf(len * sizeof(FX_WCHAR));
186 } 186 }
187 ASSERT(m_pBuffer != NULL); 187 ASSERT(m_pBuffer);
188 FX_WCHAR* str = (FX_WCHAR*)(m_pBuffer + m_DataSize); 188 FX_WCHAR* str = (FX_WCHAR*)(m_pBuffer + m_DataSize);
189 for (FX_STRSIZE i = 0; i < len; i++) { 189 for (FX_STRSIZE i = 0; i < len; i++) {
190 *str++ = buf[i]; 190 *str++ = buf[i];
191 } 191 }
192 m_DataSize += len * sizeof(FX_WCHAR); 192 m_DataSize += len * sizeof(FX_WCHAR);
193 return *this; 193 return *this;
194 } 194 }
195 CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const FX_WCHAR* lpsz) { 195 CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const FX_WCHAR* lpsz) {
196 AppendBlock(lpsz, FXSYS_wcslen(lpsz) * sizeof(FX_WCHAR)); 196 AppendBlock(lpsz, FXSYS_wcslen(lpsz) * sizeof(FX_WCHAR));
197 return *this; 197 return *this;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 } 324 }
325 FX_BOOL CFX_FileBufferArchive::DoWork(const void* pBuf, size_t size) { 325 FX_BOOL CFX_FileBufferArchive::DoWork(const void* pBuf, size_t size) {
326 if (!m_pFile) { 326 if (!m_pFile) {
327 return FALSE; 327 return FALSE;
328 } 328 }
329 if (!pBuf || size < 1) { 329 if (!pBuf || size < 1) {
330 return TRUE; 330 return TRUE;
331 } 331 }
332 return m_pFile->WriteBlock(pBuf, size); 332 return m_pFile->WriteBlock(pBuf, size);
333 } 333 }
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_basic_bstring.cpp ('k') | core/src/fxcrt/fx_basic_list.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698