summaryrefslogtreecommitdiff
path: root/core/src/fxcrt
AgeCommit message (Collapse)Author
2015-05-01Save 8 bytes in each CFX_ByteString/WideString (on "LP64" platforms).Tom Sepez
(Also makes the calculation robust in face of changes to the header). BUG=pdfium:149 R=thestig@chromium.org Review URL: https://codereview.chromium.org/1118983003
2015-04-30Take adavange of unused bytes at end of widestringTom Sepez
Follow-on to https://codereview.chromium.org/1120703003/ R=thestig@chromium.org Review URL: https://codereview.chromium.org/1112423003
2015-04-30Try to take advantage of unused bytes at end of CFX_ByteString.Tom Sepez
Given the representation of StringData, it seems sub-optimal not to be doing this. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1120703003
2015-04-28Make CFX_WideString::LockBuffer() completely unused.Tom Sepez
Then remove CFX_{Wide,Byte}String::LockBuffer(). Prelude to a vast simplification. There's an additional copy now in one place, so shoot me. BUG=pdfium:144 R=thestig@chromium.org Committed: https://pdfium.googlesource.com/pdfium/+/ee7412f5aef353e5c6f1a64d0e1708ed926869d9 Committed: https://pdfium.googlesource.com/pdfium/+/5a256ad29483eb2b13e6e2c89fe0f77a9103f68f Review URL: https://codereview.chromium.org/1053613004
2015-04-28Revert "Make CFX_WideString::LockBuffer() completely unused."Tom Sepez
This reverts commit 5a256ad29483eb2b13e6e2c89fe0f77a9103f68f. Reason for revert: broke JS tests. TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1112673002
2015-04-28Make CFX_WideString::LockBuffer() completely unused.Tom Sepez
Then remove CFX_{Wide,Byte}String::LockBuffer(). Prelude to a vast simplification. There's an additional copy now in one place, so shoot me. BUG=pdfium:144 R=thestig@chromium.org Committed: https://pdfium.googlesource.com/pdfium/+/ee7412f5aef353e5c6f1a64d0e1708ed926869d9 Review URL: https://codereview.chromium.org/1053613004
2015-04-27Revert "Make CFX_WideString::LockBuffer() completely unused."Tom Sepez
This reverts commit ee7412f5aef353e5c6f1a64d0e1708ed926869d9. Reason for revert: VS compile broke. TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1106333003
2015-04-27Make CFX_WideString::LockBuffer() completely unused.Tom Sepez
Then remove CFX_{Wide,Byte}String::LockBuffer(). Prelude to a vast simplification. There's an additional copy now in one place, so shoot me. BUG=pdfium:144 R=thestig@chromium.org Review URL: https://codereview.chromium.org/1053613004
2015-04-27Fix windows-specific usage of CFX_WideStr::operator LPCWSTR().Tom Sepez
Carry-on from https://codereview.chromium.org/1108903002/ R=brucedawson@chromium.org Review URL: https://codereview.chromium.org/1103343002
2015-04-27Reduce usage of operator LPCWSTR from CFX_WideString().Tom Sepez
This involves adding some explicit c_str() calls. Doing so flagged PDF_EncodeText() and FindOptionValue() as having suboptimal signatures, in that we are often throwing away a perfectly fine length and recomputing it. There are still some platform-specific code that needs the operator. R=brucedawson@chromium.org Review URL: https://codereview.chromium.org/1101933003
2015-04-27Revert "Kill operator LPCWSTR from CFX_WideString()."Tom Sepez
This reverts commit 15a62973b9b89c3e229cc0ab501c45967f91b325. Reason for revert: broke build on windows, mac. I must have missed some platform-specific conversions. TBR=brucedawson@chromium.org Review URL: https://codereview.chromium.org/1108883002
2015-04-27Kill operator LPCWSTR from CFX_WideString().Tom Sepez
This involves adding some explicit c_str() calls. Doing so flagged PDF_EncodeText() and FindOptionValue() as having suboptimal signatures, in that we are often throwing away a perfectly fine length and recomputing it. R=brucedawson@chromium.org Review URL: https://codereview.chromium.org/1101933003
2015-04-22Add missing operators for CFX_WideStringC.Tom Sepez
Part 2 of 4. R=thestig@chromium.org TBR=brucedawson@chromium.org BUG=pdfium:142 Review URL: https://codereview.chromium.org/1099193002
2015-04-22Add missing operators for CFX_ByteStringC.Tom Sepez
Removing the implicit cast operator forces a build breakage should we use ByteStringC in STL containers. Adding an operator< restores correct behaviour. Adding an operator[] avoids re-writing some code to call GetPtr() prior to array indexing. Part 1 of 4. R=thestig@chromium.org TBR=brucedawson@chromium.org BUG=pdfium:142. Review URL: https://codereview.chromium.org/1090303003
2015-04-22Add missing operators for CFX_WideStringTom Sepez
Part 4 of 4. BUG=pdfium:142 R=brucedawson@chromium.org, thestig@chromium.org Review URL: https://codereview.chromium.org/1084293003
2015-04-22Add missing operators for CFX_ByteString.Tom Sepez
Part 3 of 4. BUG=pdfium:142 R=brucedawson@chromium.org, thestig@chromium.org Review URL: https://codereview.chromium.org/1099213002
2015-04-21Kill CFX_StringBufTemplate.Tom Sepez
It's unused. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1098203002
2015-04-17Fix all remaining instances of FX_NEW.Tom Sepez
R=thestig@chromium.org Review URL: https://codereview.chromium.org/1084613006
2015-04-15Remove checks in fxcrt now that FX_NEW can't return 0.Tom Sepez
Replace them with |new| so that we can tell by the presence of FX_NEW the places that still need to be audited. R=thestig@google.com, thestig@chromium.org Review URL: https://codereview.chromium.org/1052553006
2015-04-14Kill CFX_Object.Tom Sepez
CFX_Object is a type that implements its own new operators that return NULL on error. There's no need for this given the |new (std::nothrow)| syntax; in fact, the current code can only work if there is no activity in the constructors. This may explain the pervasive lack of constructors and reliance on Init() methods throughout the codebase. The activity takes place in fx_memory.h, where FX_NEW is mapped onto the std::nothrow syntax. The rest is just cleanup. Down the road, we will simply throw and remove all the error-checking paths for new objects. Landing this patch first will at least show a simple path back to the old behaviour without having to re-introduce CFX_Object should someone want to do so in their own fork. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1088733002
2015-04-10Better fix for snprintf non-termination on windows.Tom Sepez
Replaces https://codereview.chromium.org/1062983002/ BUG=469244 R=brucedawson@chromium.org Review URL: https://codereview.chromium.org/1077903002
2015-04-07Fix a stack overflow issue caused by an invalid usage of snprintfJun Fang
BUG=469244 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1062983002
2015-03-12Revert "Kill CFX_GrowOnlyPool."Tom Sepez
This reverts commit 090d683489bfa3f36f1e2624c310ff9ca5836038. Symbol appears in files that are not compiled anywhere, it would seem. Reverting to remove these first. TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1001023003
2015-03-12Kill CFX_GrowOnlyPool.Tom Sepez
It's unused, and when the time comes, we'll want to put pdfium onto a hardened allocator like partitionAlloc anyways. Along the way, merge adjacent #ifdef __cplusplus blocks, remove a pointless check for __cplusplus inside a .cpp file, and remove a redundant cast. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1008483002
2015-03-10Kill remaining sprintfsTom Sepez
I thought I had done this already, apart from the third-party libraries, but there were a couple remaining (the third-party libraries will still call this, they should be tweaked upstream as needed). R=thestig@chromium.org Review URL: https://codereview.chromium.org/999543002
2015-02-05Kill off some more unreachable fopen's.Tom Sepez
The bstring's read from file is unused. The load from file paths aren't taken. R=jam@chromium.org Review URL: https://codereview.chromium.org/902943003
2015-02-05Add namespace and-re-arrange PDFium's local copy of chromium /base.Tom Sepez
Any projects DEPS'd into chromium and requiring a /base subset should have a local copy of that subset in a separate namespace. This will avoid future naming conflicts. Re-arrange the directory structure to better identify what came from chromium's base, and to make drop-in replacement easier for files that contain hard-coded "base/" in their #include directives. R=jam@chromium.org Review URL: https://codereview.chromium.org/900753002
2015-02-04Prevent base::CheckedNumeric from leaking outside of pdfium.Tom Sepez
Headers in /include directories should be free of implementation details from third_party. Put the types into a new header outside of /include. Requires https://codereview.chromium.org/902443003/ before a version containing this patch is rolled into chromium. R=jam@chromium.org Review URL: https://codereview.chromium.org/896023003
2015-01-21Simplify UTF16LE_Encode and add unittest.Bo Xu
Previously, UTF16LE_Encode take an optional flag to indicate if the returned byte string has trailing zeros. In fact, no where needs the flag to be false. So just get rid of it so callers won't misuse. The bug is found by https://codereview.chromium.org/837723009 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/860973002
2015-01-12Merge to master: Fix include paths for pdfium_unittests under chromium checkoutTom Sepez
Orignal CL at https://codereview.chromium.org/852493002/ TBR=bo_xu@foxitsoftware.com Review URL: https://codereview.chromium.org/849603003
2015-01-09Fix -Wnon-virtual-dtor compiler warnings.Tom Sepez
This is done by explicitly adding a virtual dtor to interface classes, since the cost is small given that there are already virtual functions. The exceptions are for classes that have a Release() or Delete() method, in which case it is non-virtual and protected to indicate that the virtual class is never the deletion point. BUG= R=brucedawson@chromium.org, thestig@chromium.org Review URL: https://codereview.chromium.org/810883005
2015-01-07Finish unit test for CFX_ByteStringC class.Tom Sepez
This fixes a few cut-n-paste errors in the previous version, plus adds more corner cases. The implementation is fixed to handle a few of these that failed. R=brucedawson@chromium.org Review URL: https://codereview.chromium.org/808553013
2015-01-07Add ostream helpers for FX String classes.Tom Sepez
This allows integration with the gtest EXPECT_* macros. R=brucedawson@chromium.org Review URL: https://codereview.chromium.org/837843002
2014-12-30Get rid of FX_LPCSTR cast.Bo Xu
Follow up on https://codereview.chromium.org/733693003 R=brucedawson@chromium.org, tsepez@chromium.org Review URL: https://codereview.chromium.org/809993004
2014-12-29Create pdfium_unittests binary.Tom Sepez
PDFium has not yet had a unit-tests binary, so introduce one based on the typical gtest framework. Also provide a small initial test fragment for fxcrt strings for instructional purposes. Naturally, doing so kicked out one corner case that isn't handled, we'll fix that in a separate patch. This is a small part of the testing strategy tracking bug. BUG=https://code.google.com/p/pdfium/issues/detail?id=62 R=brucedawson@chromium.org, palmer@chromium.org Review URL: https://codereview.chromium.org/831653002
2014-12-08Getting rid of more (FX_LPCWSTR) casts and fixing two bugs revealed by this.Bruce Dawson
Since casts to FX_LPCWSTR have been shown to hide bugs I tried removing more of them, targeting those places where a cast was used to force a conversion from CFX_WideString to FX_LPCWSTR, replacing these casts with calls to the newly added .c_str() function. This revealed two places where the cast was hiding a bug -- where ->c_str() was required instead! This removes ~33 FX_LPCWSTR casts and there are ~31 left, many of which will go away in some future change. Also includes this change: Removing unnecessary casts from wchar_t* to wchar_t*, by various names. Original patch from Bruce Dawson(brucedawson@chromium.org) R=bo_xu@foxitsoftware.com, tsepez@chromium.org Review URL: https://codereview.chromium.org/733693003
2014-11-17Removing unnecessary casts from wchar_t* to wchar_t*, by various names.Bruce Dawson
Remove casts that merely cast from wchar_t* to wchar_t*. Sometimes the types or casts are FX_LPCWSTR but the idea is the same. Excess casts can (and have) hidden bugs so removing these may prevent future problems. Original patch from Bruce Dawson(brucedawson@chromium.org) R=bo_xu@foxitsoftware.com, tsepez@chromium.org Review URL: https://codereview.chromium.org/730993002
2014-11-17Zero initialize ch to avoid possible bug - conditions are very subtle.Bruce Dawson
Whether ch and iRet are read without being initialized depends on complex preconditions and cannot be determined by looking at these function. Therefore it seems prudent to zero initialize them to avoid any risk. BUG=427616 R=bo_xu@foxitsoftware.com Review URL: https://codereview.chromium.org/727083002
2014-11-14Remove FX_LPCWSTR cast to wchar_t* literalsBo Xu
BUG=https://code.google.com/p/pdfium/issues/detail?id=78 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/726143002
2014-09-19Fix a bug when assign the generation number of indirect objectschromium/2166chromium/2165Bo Xu
BUG=408532 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/524443002
2014-08-13Add FX_OVERRIDE and use it for virtual functions of FX_FINAL classes.Tom Sepez
Should there be cases where this fails to compile, it indicates a mistake, either an incorrectly declared overrriden virtual method, or a method that should be declared non-virtual. The only issues were with CPDF_CustomAccess::GetBlock(), CPDF_CustomAccess::GetByte(), and CPDF_CustomAccess::GetFullPath(). These don't appear to be used anywhere, and are removed. Two members are removed that are no longer needed once those methods are removed. R=jam@chromium.org, jun_fang@foxitsoftware.com Review URL: https://codereview.chromium.org/454983003
2014-08-07Change '>=' back to '>' in extension.h due to bad fixchromium/2122chromium/2121chromium/2120chromium/2119chromium/2118Jun Fang
BUG=400662 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/445303002
2014-07-31Correct the names of the FX_SAFE_* typedefs.Chris Palmer
R=jun_fang@foxitsoftware.com Review URL: https://codereview.chromium.org/417263008
2014-07-30Fix the potential integer overflow from 'offset+size' in extension.h and ↵JUN FANG
fpdfview.cpp BUG=397258 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/419063002
2014-07-29Remove a few unused variables, functions, and tables.Nico Weber
Found by clang's -Wunused-variable, -Wunused-function, -Wunused-const-variable. BUG=none R=bo_xu@foxitsoftware.com Review URL: https://codereview.chromium.org/404653005
2014-07-24CalRGB color correctionBo Xu
BUG=pdfium:19 R=thestig@chromium.org Review URL: https://codereview.chromium.org/403163002
2014-07-24This change is for fixing the potential integer overflow from "offset + size"JUN FANG
BUG=382667 R=palmer@chromium.org Review URL: https://codereview.chromium.org/322333002
2014-07-23Refactor CFX_BasicArray.chromium/2112chromium/2111chromium/2110chromium/2109chromium/2108chromium/2107chromium/2106chromium/2105chromium/2104Chris Palmer
The |nGrowBy| argument to |SetSize| was always -1, which caused the effective m_nGrowBy value to always be its default value: 0. So it was not needed, and was cluttering up the logic. BUG=384662 Check for integer overflow in CFX_BasicArray. BUG=384662 R=bo_xu@foxitsoftware.com, rsesek@chromium.org Review URL: https://codereview.chromium.org/415803002
2014-07-23Check for integer overflow in CFX_BasicArray.Chris Palmer
BUG=384662 R=bo_xu@foxitsoftware.com, rsesek@chromium.org Review URL: https://codereview.chromium.org/411033003
2014-07-18pdfium: Fix all -Wdelete-non-virtual-dtor violations on Mac.Nico Weber
Calling `delete` on an object of a type that has virtual functions but not a virtual destructor is questionable: Since the object has virtual functions, it likely has subclasses, so if it's deleted through the base pointer and the destructor isn't virtual, the subclass destructor won't be called. In most cases, the classes getting deleted can just be marked final to tell the compiler that it can't possibly have subclasses (this also enables the compiler to generate better code). Two classes didn't have any sub- or superclasses but virtual functions - this doesn't make sense, so make all methods of these classes non-virtual. (Also delete an unused function on one of the two classes.) In one case, a class actually did have a subclass that needs to be deleted virtually, so mark one destructor as virtual. BUG=none R=bo_xu@foxitsoftware.com Review URL: https://codereview.chromium.org/370853002