Remove spurious includes of <string.h>.
<string.h> should be banished as its functions are unsafe.
-- Fix IWYU in header files moving some inclusions from .cpp file.
-- Convert include to stdddef.h/stdint.h if size_t or uint*_t types
used directly in file.
Change-Id: If39d62d67f8f2cf3d78b5d3603fd14d9d697db35
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118913
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fdrm/fx_crypt_aes.cpp b/core/fdrm/fx_crypt_aes.cpp
index 8e5a9b7..6a15197 100644
--- a/core/fdrm/fx_crypt_aes.cpp
+++ b/core/fdrm/fx_crypt_aes.cpp
@@ -11,8 +11,6 @@
#include "core/fdrm/fx_crypt_aes.h"
-#include <string.h>
-
#include "core/fxcrt/byteorder.h"
#include "core/fxcrt/check.h"
#include "core/fxcrt/check_op.h"
diff --git a/core/fdrm/fx_crypt_sha.cpp b/core/fdrm/fx_crypt_sha.cpp
index ee07ceb..5dd6006 100644
--- a/core/fdrm/fx_crypt_sha.cpp
+++ b/core/fdrm/fx_crypt_sha.cpp
@@ -10,11 +10,9 @@
#endif
#include "core/fdrm/fx_crypt_sha.h"
-#include "core/fxcrt/stl_util.h"
-
-#include <string.h>
#include "core/fxcrt/fx_memcpy_wrappers.h"
+#include "core/fxcrt/stl_util.h"
#define SHA_GET_UINT32(n, b, i) \
{ \
diff --git a/core/fpdfapi/page/cpdf_colorspace_unittest.cpp b/core/fpdfapi/page/cpdf_colorspace_unittest.cpp
index 4e60207..e0499ed 100644
--- a/core/fpdfapi/page/cpdf_colorspace_unittest.cpp
+++ b/core/fpdfapi/page/cpdf_colorspace_unittest.cpp
@@ -9,6 +9,7 @@
#include "core/fpdfapi/page/cpdf_colorspace.h"
+#include <stddef.h>
#include <stdint.h>
#include "core/fxcrt/retain_ptr.h"
diff --git a/core/fxcodec/flate/flatemodule.cpp b/core/fxcodec/flate/flatemodule.cpp
index 0882d93..cb3cd95 100644
--- a/core/fxcodec/flate/flatemodule.cpp
+++ b/core/fxcodec/flate/flatemodule.cpp
@@ -11,8 +11,7 @@
#include "core/fxcodec/flate/flatemodule.h"
-#include <stdint.h>
-#include <string.h>
+#include <stddef.h>
#include <algorithm>
#include <limits>
diff --git a/core/fxcodec/gif/lzw_decompressor.cpp b/core/fxcodec/gif/lzw_decompressor.cpp
index db46759..05da330 100644
--- a/core/fxcodec/gif/lzw_decompressor.cpp
+++ b/core/fxcodec/gif/lzw_decompressor.cpp
@@ -11,8 +11,6 @@
#include "core/fxcodec/gif/lzw_decompressor.h"
-#include <string.h>
-
#include <algorithm>
#include <memory>
#include <type_traits>
diff --git a/core/fxcodec/gif/lzw_decompressor.h b/core/fxcodec/gif/lzw_decompressor.h
index c078fc8..5b2b580 100644
--- a/core/fxcodec/gif/lzw_decompressor.h
+++ b/core/fxcodec/gif/lzw_decompressor.h
@@ -7,6 +7,7 @@
#ifndef CORE_FXCODEC_GIF_LZW_DECOMPRESSOR_H_
#define CORE_FXCODEC_GIF_LZW_DECOMPRESSOR_H_
+#include <stddef.h>
#include <stdint.h>
#include <memory>
diff --git a/core/fxcodec/jbig2/JBig2_Context.cpp b/core/fxcodec/jbig2/JBig2_Context.cpp
index fa5f8d8..9a0d600 100644
--- a/core/fxcodec/jbig2/JBig2_Context.cpp
+++ b/core/fxcodec/jbig2/JBig2_Context.cpp
@@ -11,8 +11,6 @@
#include "core/fxcodec/jbig2/JBig2_Context.h"
-#include <string.h>
-
#include <algorithm>
#include <limits>
#include <list>
diff --git a/core/fxcodec/jbig2/JBig2_Context.h b/core/fxcodec/jbig2/JBig2_Context.h
index 945eeed..f0c1abe 100644
--- a/core/fxcodec/jbig2/JBig2_Context.h
+++ b/core/fxcodec/jbig2/JBig2_Context.h
@@ -7,6 +7,9 @@
#ifndef CORE_FXCODEC_JBIG2_JBIG2_CONTEXT_H_
#define CORE_FXCODEC_JBIG2_JBIG2_CONTEXT_H_
+#include <stddef.h>
+#include <stdint.h>
+
#include <list>
#include <memory>
#include <utility>
diff --git a/core/fxcodec/jbig2/JBig2_Image.cpp b/core/fxcodec/jbig2/JBig2_Image.cpp
index 0b4fc75..612e212 100644
--- a/core/fxcodec/jbig2/JBig2_Image.cpp
+++ b/core/fxcodec/jbig2/JBig2_Image.cpp
@@ -12,7 +12,7 @@
#include "core/fxcodec/jbig2/JBig2_Image.h"
#include <limits.h>
-#include <string.h>
+#include <stddef.h>
#include <algorithm>
#include <memory>
diff --git a/core/fxcodec/jbig2/JBig2_Image.h b/core/fxcodec/jbig2/JBig2_Image.h
index cf2922e..8d5459b 100644
--- a/core/fxcodec/jbig2/JBig2_Image.h
+++ b/core/fxcodec/jbig2/JBig2_Image.h
@@ -12,6 +12,8 @@
#ifndef CORE_FXCODEC_JBIG2_JBIG2_IMAGE_H_
#define CORE_FXCODEC_JBIG2_JBIG2_IMAGE_H_
+#include <stdint.h>
+
#include <memory>
#include "core/fxcodec/jbig2/JBig2_Define.h"
diff --git a/core/fxcodec/jbig2/JBig2_SddProc.cpp b/core/fxcodec/jbig2/JBig2_SddProc.cpp
index 57988a8..b58653a 100644
--- a/core/fxcodec/jbig2/JBig2_SddProc.cpp
+++ b/core/fxcodec/jbig2/JBig2_SddProc.cpp
@@ -11,7 +11,7 @@
#include "core/fxcodec/jbig2/JBig2_SddProc.h"
-#include <string.h>
+#include <stddef.h>
#include <algorithm>
#include <memory>
diff --git a/core/fxcodec/jbig2/jbig2_decoder.cpp b/core/fxcodec/jbig2/jbig2_decoder.cpp
index 346154d..a0f72da 100644
--- a/core/fxcodec/jbig2/jbig2_decoder.cpp
+++ b/core/fxcodec/jbig2/jbig2_decoder.cpp
@@ -11,8 +11,6 @@
#include "core/fxcodec/jbig2/jbig2_decoder.h"
-#include <string.h>
-
#include "core/fxcodec/jbig2/JBig2_Context.h"
#include "core/fxcodec/jbig2/JBig2_DocumentContext.h"
#include "core/fxcrt/fx_2d_size.h"
diff --git a/core/fxcodec/jbig2/jbig2_decoder.h b/core/fxcodec/jbig2/jbig2_decoder.h
index bdaa5ef..644a611 100644
--- a/core/fxcodec/jbig2/jbig2_decoder.h
+++ b/core/fxcodec/jbig2/jbig2_decoder.h
@@ -7,6 +7,8 @@
#ifndef CORE_FXCODEC_JBIG2_JBIG2_DECODER_H_
#define CORE_FXCODEC_JBIG2_JBIG2_DECODER_H_
+#include <stdint.h>
+
#include <memory>
#include "core/fxcodec/fx_codec_def.h"
diff --git a/core/fxcodec/jpeg/jpegmodule.cpp b/core/fxcodec/jpeg/jpegmodule.cpp
index e86e598..ca86032 100644
--- a/core/fxcodec/jpeg/jpegmodule.cpp
+++ b/core/fxcodec/jpeg/jpegmodule.cpp
@@ -12,8 +12,6 @@
#include "core/fxcodec/jpeg/jpegmodule.h"
#include <setjmp.h>
-#include <stdint.h>
-#include <string.h>
#include <memory>
#include <optional>
diff --git a/core/fxcodec/jpeg/jpegmodule.h b/core/fxcodec/jpeg/jpegmodule.h
index dc132fc..0d479f5 100644
--- a/core/fxcodec/jpeg/jpegmodule.h
+++ b/core/fxcodec/jpeg/jpegmodule.h
@@ -7,6 +7,7 @@
#ifndef CORE_FXCODEC_JPEG_JPEGMODULE_H_
#define CORE_FXCODEC_JPEG_JPEGMODULE_H_
+#include <stddef.h>
#include <stdint.h>
#include <memory>
diff --git a/core/fxcodec/jpx/jpx_decode_utils.cpp b/core/fxcodec/jpx/jpx_decode_utils.cpp
index cfa598c..d4f3254 100644
--- a/core/fxcodec/jpx/jpx_decode_utils.cpp
+++ b/core/fxcodec/jpx/jpx_decode_utils.cpp
@@ -11,9 +11,6 @@
#include "core/fxcodec/jpx/jpx_decode_utils.h"
-#include <stddef.h>
-#include <string.h>
-
#include <algorithm>
#include <limits>
#include <type_traits>
diff --git a/core/fxge/cfx_cliprgn.cpp b/core/fxge/cfx_cliprgn.cpp
index ef56b28..1046cf4 100644
--- a/core/fxge/cfx_cliprgn.cpp
+++ b/core/fxge/cfx_cliprgn.cpp
@@ -11,7 +11,7 @@
#include "core/fxge/cfx_cliprgn.h"
-#include <string.h>
+#include <stdint.h>
#include <utility>
diff --git a/core/fxge/dib/cfx_bitmapcomposer.cpp b/core/fxge/dib/cfx_bitmapcomposer.cpp
index c60cedc..c25c48b 100644
--- a/core/fxge/dib/cfx_bitmapcomposer.cpp
+++ b/core/fxge/dib/cfx_bitmapcomposer.cpp
@@ -11,7 +11,7 @@
#include "core/fxge/dib/cfx_bitmapcomposer.h"
-#include <string.h>
+#include <stddef.h>
#include "core/fxcrt/check_op.h"
#include "core/fxcrt/fx_2d_size.h"
diff --git a/core/fxge/dib/cfx_bitmapstorer.cpp b/core/fxge/dib/cfx_bitmapstorer.cpp
index 2f85129..a04d978 100644
--- a/core/fxge/dib/cfx_bitmapstorer.cpp
+++ b/core/fxge/dib/cfx_bitmapstorer.cpp
@@ -6,8 +6,6 @@
#include "core/fxge/dib/cfx_bitmapstorer.h"
-#include <string.h>
-
#include <utility>
#include "core/fxcrt/check_op.h"
diff --git a/core/fxge/dib/cfx_bitmapstorer.h b/core/fxge/dib/cfx_bitmapstorer.h
index ee75ccc..a83bdb6 100644
--- a/core/fxge/dib/cfx_bitmapstorer.h
+++ b/core/fxge/dib/cfx_bitmapstorer.h
@@ -7,6 +7,8 @@
#ifndef CORE_FXGE_DIB_CFX_BITMAPSTORER_H_
#define CORE_FXGE_DIB_CFX_BITMAPSTORER_H_
+#include <stdint.h>
+
#include "core/fxcrt/retain_ptr.h"
#include "core/fxcrt/span.h"
#include "core/fxge/dib/scanlinecomposer_iface.h"
diff --git a/core/fxge/dib/cfx_dibbase.cpp b/core/fxge/dib/cfx_dibbase.cpp
index b21aafc..1117dde 100644
--- a/core/fxge/dib/cfx_dibbase.cpp
+++ b/core/fxge/dib/cfx_dibbase.cpp
@@ -11,9 +11,6 @@
#include "core/fxge/dib/cfx_dibbase.h"
-#include <stdint.h>
-#include <string.h>
-
#include <algorithm>
#include <utility>
#include <vector>
diff --git a/core/fxge/dib/cfx_dibbase.h b/core/fxge/dib/cfx_dibbase.h
index bbfecdb..12677ed 100644
--- a/core/fxge/dib/cfx_dibbase.h
+++ b/core/fxge/dib/cfx_dibbase.h
@@ -7,6 +7,7 @@
#ifndef CORE_FXGE_DIB_CFX_DIBBASE_H_
#define CORE_FXGE_DIB_CFX_DIBBASE_H_
+#include <stddef.h>
#include <stdint.h>
#include "build/build_config.h"
diff --git a/core/fxge/dib/cfx_dibitmap.cpp b/core/fxge/dib/cfx_dibitmap.cpp
index 30420b4..d065266 100644
--- a/core/fxge/dib/cfx_dibitmap.cpp
+++ b/core/fxge/dib/cfx_dibitmap.cpp
@@ -11,9 +11,6 @@
#include "core/fxge/dib/cfx_dibitmap.h"
-#include <stdint.h>
-#include <string.h>
-
#include <limits>
#include <memory>
#include <utility>
diff --git a/core/fxge/dib/cfx_dibitmap.h b/core/fxge/dib/cfx_dibitmap.h
index 0256f33..bd9d9b4 100644
--- a/core/fxge/dib/cfx_dibitmap.h
+++ b/core/fxge/dib/cfx_dibitmap.h
@@ -7,6 +7,9 @@
#ifndef CORE_FXGE_DIB_CFX_DIBITMAP_H_
#define CORE_FXGE_DIB_CFX_DIBITMAP_H_
+#include <stddef.h>
+#include <stdint.h>
+
#include <optional>
#include "core/fxcrt/compiler_specific.h"
diff --git a/core/fxge/dib/cfx_scanlinecompositor.cpp b/core/fxge/dib/cfx_scanlinecompositor.cpp
index a85b8b1..acd2073 100644
--- a/core/fxge/dib/cfx_scanlinecompositor.cpp
+++ b/core/fxge/dib/cfx_scanlinecompositor.cpp
@@ -11,8 +11,6 @@
#include "core/fxge/dib/cfx_scanlinecompositor.h"
-#include <string.h>
-
#include <algorithm>
#include "core/fxcrt/check.h"
diff --git a/core/fxge/dib/cfx_scanlinecompositor.h b/core/fxge/dib/cfx_scanlinecompositor.h
index 6ee991d..8854bb4 100644
--- a/core/fxge/dib/cfx_scanlinecompositor.h
+++ b/core/fxge/dib/cfx_scanlinecompositor.h
@@ -7,6 +7,9 @@
#ifndef CORE_FXGE_DIB_CFX_SCANLINECOMPOSITOR_H_
#define CORE_FXGE_DIB_CFX_SCANLINECOMPOSITOR_H_
+#include <stddef.h>
+#include <stdint.h>
+
#include <memory>
#include "core/fxcrt/fx_memory_wrappers.h"
diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp
index 0dc0541..7c4231c 100644
--- a/core/fxge/win32/cfx_psrenderer.cpp
+++ b/core/fxge/win32/cfx_psrenderer.cpp
@@ -12,7 +12,6 @@
#include "core/fxge/win32/cfx_psrenderer.h"
#include <math.h>
-#include <string.h>
#include <algorithm>
#include <array>
diff --git a/core/fxge/win32/ctext_only_printer_driver.cpp b/core/fxge/win32/ctext_only_printer_driver.cpp
index 704a3bb..aafc7c5 100644
--- a/core/fxge/win32/ctext_only_printer_driver.cpp
+++ b/core/fxge/win32/ctext_only_printer_driver.cpp
@@ -11,8 +11,6 @@
#include <limits.h>
#include <stddef.h>
-#include <stdint.h>
-#include <string.h>
#include <algorithm>
diff --git a/core/fxge/win32/ctext_only_printer_driver.h b/core/fxge/win32/ctext_only_printer_driver.h
index 21f8ed5..3c2754d 100644
--- a/core/fxge/win32/ctext_only_printer_driver.h
+++ b/core/fxge/win32/ctext_only_printer_driver.h
@@ -5,6 +5,7 @@
#ifndef CORE_FXGE_WIN32_CTEXT_ONLY_PRINTER_DRIVER_H_
#define CORE_FXGE_WIN32_CTEXT_ONLY_PRINTER_DRIVER_H_
+#include <stdint.h>
#include <windows.h>
#include <memory>
diff --git a/testing/test_loader.cpp b/testing/test_loader.cpp
index 7c934b9..71fa274 100644
--- a/testing/test_loader.cpp
+++ b/testing/test_loader.cpp
@@ -4,7 +4,7 @@
#include "testing/test_loader.h"
-#include <string.h>
+#include <stddef.h>
#include "core/fxcrt/check_op.h"
#include "core/fxcrt/fx_memcpy_wrappers.h"