Remove flags param from FXMEM_DefaultAlloc() and friends.

Change-Id: I24404be0065156a1cfdec31bafdf72c27fa70142
Reviewed-on: https://pdfium-review.googlesource.com/17792
Reviewed-by: Chris Palmer <palmer@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxcodec/codec/ccodec_tiffmodule.cpp b/core/fxcodec/codec/ccodec_tiffmodule.cpp
index a5b70c6..0bf0045 100644
--- a/core/fxcodec/codec/ccodec_tiffmodule.cpp
+++ b/core/fxcodec/codec/ccodec_tiffmodule.cpp
@@ -69,16 +69,16 @@
 }
 
 void* _TIFFmalloc(tmsize_t size) {
-  return FXMEM_DefaultAlloc(size, 0);
+  return FXMEM_DefaultAlloc(size);
 }
 
 void _TIFFfree(void* ptr) {
   if (ptr)
-    FXMEM_DefaultFree(ptr, 0);
+    FXMEM_DefaultFree(ptr);
 }
 
 void* _TIFFrealloc(void* ptr, tmsize_t size) {
-  return FXMEM_DefaultRealloc(ptr, size, 0);
+  return FXMEM_DefaultRealloc(ptr, size);
 }
 
 void _TIFFmemset(void* ptr, int val, tmsize_t size) {
diff --git a/core/fxcrt/fx_memory.cpp b/core/fxcrt/fx_memory.cpp
index 6a592a1..6a135ae 100644
--- a/core/fxcrt/fx_memory.cpp
+++ b/core/fxcrt/fx_memory.cpp
@@ -24,8 +24,7 @@
   }
 }
 
-// TODO(palmer): Remove the |flags| argument.
-void* FXMEM_DefaultAlloc(size_t byte_size, int flags) {
+void* FXMEM_DefaultAlloc(size_t byte_size) {
   return pdfium::base::PartitionAllocGenericFlags(
       gGeneralPartitionAllocator.root(), pdfium::base::PartitionAllocReturnNull,
       byte_size, "GeneralPartition");
@@ -35,14 +34,12 @@
   return FX_SafeAlloc(num_elems, byte_size);
 }
 
-// TODO(palmer): Remove the |flags| argument.
-void* FXMEM_DefaultRealloc(void* pointer, size_t new_size, int flags) {
+void* FXMEM_DefaultRealloc(void* pointer, size_t new_size) {
   return pdfium::base::PartitionReallocGeneric(
       gGeneralPartitionAllocator.root(), pointer, new_size, "GeneralPartition");
 }
 
-// TODO(palmer): Remove the |flags| argument.
-void FXMEM_DefaultFree(void* pointer, int flags) {
+void FXMEM_DefaultFree(void* pointer) {
   pdfium::base::PartitionFree(pointer);
 }
 
diff --git a/core/fxcrt/fx_memory.h b/core/fxcrt/fx_memory.h
index f89095a..ecf3e42 100644
--- a/core/fxcrt/fx_memory.h
+++ b/core/fxcrt/fx_memory.h
@@ -14,10 +14,10 @@
 #endif
 
 // For external C libraries to malloc through PDFium. These may return nullptr.
-void* FXMEM_DefaultAlloc(size_t byte_size, int flags);
+void* FXMEM_DefaultAlloc(size_t byte_size);
 void* FXMEM_DefaultCalloc(size_t num_elems, size_t byte_size);
-void* FXMEM_DefaultRealloc(void* pointer, size_t new_size, int flags);
-void FXMEM_DefaultFree(void* pointer, int flags);
+void* FXMEM_DefaultRealloc(void* pointer, size_t new_size);
+void FXMEM_DefaultFree(void* pointer);
 
 #ifdef __cplusplus
 }  // extern "C"
diff --git a/core/fxcrt/fx_memory_unittest.cpp b/core/fxcrt/fx_memory_unittest.cpp
index ae15db2..2856bb9 100644
--- a/core/fxcrt/fx_memory_unittest.cpp
+++ b/core/fxcrt/fx_memory_unittest.cpp
@@ -72,10 +72,10 @@
 }
 
 TEST(fxcrt, DISABLED_FXMEM_DefaultOOM) {
-  EXPECT_FALSE(FXMEM_DefaultAlloc(kMaxByteAlloc, 0));
+  EXPECT_FALSE(FXMEM_DefaultAlloc(kMaxByteAlloc));
 
-  void* ptr = FXMEM_DefaultAlloc(1, 0);
+  void* ptr = FXMEM_DefaultAlloc(1);
   EXPECT_TRUE(ptr);
-  EXPECT_FALSE(FXMEM_DefaultRealloc(ptr, kMaxByteAlloc, 0));
-  FXMEM_DefaultFree(ptr, 0);
+  EXPECT_FALSE(FXMEM_DefaultRealloc(ptr, kMaxByteAlloc));
+  FXMEM_DefaultFree(ptr);
 }
diff --git a/third_party/lcms/0000-cmserr-changes.patch b/third_party/lcms/0000-cmserr-changes.patch
index 5ccaac9..baf3577 100644
--- a/third_party/lcms/0000-cmserr-changes.patch
+++ b/third_party/lcms/0000-cmserr-changes.patch
@@ -51,7 +51,7 @@
 +// Generic allocate
 +void* CMSEXPORT _cmsMalloc(cmsContext ContextID, cmsUInt32Number size)
 +{
-+    return FXMEM_DefaultAlloc(size, 1);
++    return FXMEM_DefaultAlloc(size);
  }
  
  // Generic allocate & zero
@@ -64,7 +64,7 @@
 -
 -    memset(pt, 0, size);
 -    return pt;
-+    void* p = FXMEM_DefaultAlloc(size, 1);
++    void* p = FXMEM_DefaultAlloc(size);
 +    if (p) memset(p, 0, size);
 +    return p;
  }
@@ -101,7 +101,7 @@
 -    return realloc(Ptr, size);
 -
 -    cmsUNUSED_PARAMETER(ContextID);
-+    return FXMEM_DefaultRealloc(Ptr, size, 1);
++    return FXMEM_DefaultRealloc(Ptr, size);
  }
  
 -
@@ -128,7 +128,7 @@
 -    if (Total > MAX_MEMORY_FOR_ALLOC) return NULL;  // Never alloc over 512Mb
 -
 -    return _cmsMallocZero(ContextID, Total);
-+    if (Ptr != NULL) FXMEM_DefaultFree(Ptr, 0);
++    if (Ptr != NULL) FXMEM_DefaultFree(Ptr);
  }
  
  // Generic block duplication
@@ -146,7 +146,7 @@
 -        memmove(mem, Org, size);
 -
 -    return mem;
-+    void* p = FXMEM_DefaultAlloc(size, 1);
++    void* p = FXMEM_DefaultAlloc(size);
 +    memmove(p, Org, size);
 +    return p;
  }
diff --git a/third_party/lcms/src/cmserr.c b/third_party/lcms/src/cmserr.c
index 3c3848b..69b0550 100644
--- a/third_party/lcms/src/cmserr.c
+++ b/third_party/lcms/src/cmserr.c
@@ -75,13 +75,13 @@
 // Generic allocate
 void* CMSEXPORT _cmsMalloc(cmsContext ContextID, cmsUInt32Number size)
 {
-    return FXMEM_DefaultAlloc(size, 1);
+    return FXMEM_DefaultAlloc(size);
 }
 
 // Generic allocate & zero
 void* CMSEXPORT _cmsMallocZero(cmsContext ContextID, cmsUInt32Number size)
 {
-    void* p = FXMEM_DefaultAlloc(size, 1);
+    void* p = FXMEM_DefaultAlloc(size);
     if (p) memset(p, 0, size);
     return p;
 }
@@ -99,19 +99,19 @@
 // Generic reallocate
 void* CMSEXPORT _cmsRealloc(cmsContext ContextID, void* Ptr, cmsUInt32Number size)
 {
-    return FXMEM_DefaultRealloc(Ptr, size, 1);
+    return FXMEM_DefaultRealloc(Ptr, size);
 }
 
 // Generic free memory
 void CMSEXPORT _cmsFree(cmsContext ContextID, void* Ptr)
 {
-    if (Ptr != NULL) FXMEM_DefaultFree(Ptr, 0);
+    if (Ptr != NULL) FXMEM_DefaultFree(Ptr);
 }
 
 // Generic block duplication
 void* CMSEXPORT _cmsDupMem(cmsContext ContextID, const void* Org, cmsUInt32Number size)
 {
-    void* p = FXMEM_DefaultAlloc(size, 1);
+    void* p = FXMEM_DefaultAlloc(size);
     memmove(p, Org, size);
     return p;
 }
diff --git a/third_party/libpng16/0000-build-config.patch b/third_party/libpng16/0000-build-config.patch
index 5c30866..325b58f 100644
--- a/third_party/libpng16/0000-build-config.patch
+++ b/third_party/libpng16/0000-build-config.patch
@@ -5,8 +5,8 @@
  
  #include "pngpriv.h"
  
-+void*	FXMEM_DefaultAlloc(int byte_size, int);
-+void	FXMEM_DefaultFree(void* pointer, int);
++void*	FXMEM_DefaultAlloc(size_t byte_size);
++void	FXMEM_DefaultFree(void* pointer);
 +
  #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
  /* Free a png_struct */
@@ -16,7 +16,7 @@
        else
  #endif
 -         return malloc((size_t)size); /* checked for truncation above */
-+         return FXMEM_DefaultAlloc((int)size, 0);
++         return FXMEM_DefaultAlloc(size);
     }
  
     else
@@ -25,7 +25,7 @@
  #endif /* USER_MEM */
  
 -   free(ptr);
-+   FXMEM_DefaultFree(ptr, 0);
++   FXMEM_DefaultFree(ptr);
  }
  
  #ifdef PNG_USER_MEM_SUPPORTED
diff --git a/third_party/libpng16/pngmem.c b/third_party/libpng16/pngmem.c
index b550713..cf815a6 100644
--- a/third_party/libpng16/pngmem.c
+++ b/third_party/libpng16/pngmem.c
@@ -19,8 +19,8 @@
 
 #include "pngpriv.h"
 
-void*	FXMEM_DefaultAlloc(int byte_size, int);
-void	FXMEM_DefaultFree(void* pointer, int);
+void*	FXMEM_DefaultAlloc(size_t byte_size);
+void	FXMEM_DefaultFree(void* pointer);
 
 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
 /* Free a png_struct */
@@ -95,7 +95,7 @@
 
       else
 #endif
-         return FXMEM_DefaultAlloc((int)size, 0);
+         return FXMEM_DefaultAlloc(size);
    }
 
    else
@@ -252,7 +252,7 @@
       return;
 #endif /* USER_MEM */
 
-   FXMEM_DefaultFree(ptr, 0);
+   FXMEM_DefaultFree(ptr);
 }
 
 #ifdef PNG_USER_MEM_SUPPORTED