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

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

Issue 372473003: Remove custom memory manager (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Change malloc to calloc Created 6 years, 5 months 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_array.cpp ('k') | core/src/fxcrt/fx_basic_buffer.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 "../../include/fxcrt/fx_basic.h" 7 #include "../../include/fxcrt/fx_basic.h"
8 static int _Buffer_itoa(char* buf, int i, FX_DWORD flags) 8 static int _Buffer_itoa(char* buf, int i, FX_DWORD flags)
9 { 9 {
10 if (i == 0) { 10 if (i == 0) {
11 buf[0] = '0'; 11 buf[0] = '0';
12 return 1; 12 return 1;
13 } 13 }
14 char buf1[32]; 14 char buf1[32];
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 FX_CHAR* pBuffer = (FX_CHAR*)(this + 1); 1163 FX_CHAR* pBuffer = (FX_CHAR*)(this + 1);
1164 FXSYS_memcpy32(pBuffer + m_Size, str.GetPtr(), len); 1164 FXSYS_memcpy32(pBuffer + m_Size, str.GetPtr(), len);
1165 m_Size += len; 1165 m_Size += len;
1166 } 1166 }
1167 void CFX_StringBufBase::Append(int i, FX_DWORD flags) 1167 void CFX_StringBufBase::Append(int i, FX_DWORD flags)
1168 { 1168 {
1169 char buf[32]; 1169 char buf[32];
1170 int len = _Buffer_itoa(buf, i, flags); 1170 int len = _Buffer_itoa(buf, i, flags);
1171 Append(CFX_ByteStringC(buf, len)); 1171 Append(CFX_ByteStringC(buf, len));
1172 } 1172 }
1173 void CFX_ByteStringL::Empty(IFX_Allocator* pAllocator)
1174 {
1175 if (m_Ptr) {
1176 FX_Allocator_Free(pAllocator, (FX_LPVOID)m_Ptr);
1177 }
1178 m_Ptr = NULL, m_Length = 0;
1179 }
1180 FX_LPSTR CFX_ByteStringL::AllocBuffer(FX_STRSIZE length, IFX_Allocator* pAllocat or)
1181 {
1182 Empty(pAllocator);
1183 FX_LPSTR str = FX_Allocator_Alloc(pAllocator, FX_CHAR, length + 1);
1184 if (!str) {
1185 return NULL;
1186 }
1187 *(FX_LPSTR*)(&m_Ptr) = str;
1188 m_Length = length;
1189 return str;
1190 }
1191 void CFX_ByteStringL::Set(FX_BSTR src, IFX_Allocator* pAllocator)
1192 {
1193 Empty(pAllocator);
1194 if (src.GetCStr() != NULL && src.GetLength() > 0) {
1195 FX_LPSTR str = FX_Allocator_Alloc(pAllocator, FX_CHAR, src.GetLength() + 1);
1196 if (!str) {
1197 return;
1198 }
1199 FXSYS_memcpy32(str, src, src.GetLength());
1200 str[src.GetLength()] = '\0';
1201 *(FX_LPSTR*)(&m_Ptr) = str;
1202 m_Length = src.GetLength();
1203 }
1204 }
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_basic_array.cpp ('k') | core/src/fxcrt/fx_basic_buffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698