diff --git a/oss-internship-2020/libpng/examples/example1.cc b/oss-internship-2020/libpng/examples/example1.cc index 49b7ff5..d4b0cba 100644 --- a/oss-internship-2020/libpng/examples/example1.cc +++ b/oss-internship-2020/libpng/examples/example1.cc @@ -14,7 +14,7 @@ #include -#include "../sandboxed.h" // NOLINT(build/include) +#include "../sandboxed.h" // NOLINT(build/include) #include "../tests/libpng.h" // NOLINT(build/include) #include "sandboxed_api/vars.h" @@ -51,19 +51,18 @@ absl::Status LibPNGMain(const std::string& infile, const std::string& outfile) { free(buffer); sapi::v::Array buffer_(PNG_IMAGE_SIZE(*image.mutable_data())); - SAPI_ASSIGN_OR_RETURN( - result, api.png_image_finish_read( - image.PtrBoth(), sapi::v::NullPtr().PtrBoth(), - buffer_.PtrBoth(), 0, sapi::v::NullPtr().PtrBoth())); + sapi::v::NullPtr null = sapi::v::NullPtr(); + SAPI_ASSIGN_OR_RETURN(result, + api.png_image_finish_read(image.PtrBoth(), &null, + buffer_.PtrBoth(), 0, &null)); if (!result) { return absl::InternalError( absl::StrCat("finish read error: ", image.mutable_data()->message)); } - SAPI_ASSIGN_OR_RETURN( - result, api.png_image_write_to_file( - image.PtrBoth(), outfile_var.PtrBefore(), 0, - buffer_.PtrBoth(), 0, sapi::v::NullPtr().PtrBoth())); + SAPI_ASSIGN_OR_RETURN(result, api.png_image_write_to_file( + image.PtrBoth(), outfile_var.PtrBefore(), 0, + buffer_.PtrBoth(), 0, &null)); if (!result) { return absl::InternalError( absl::StrCat("write error: ", image.mutable_data()->message)); @@ -87,4 +86,3 @@ int main(int argc, const char** argv) { return EXIT_SUCCESS; } - diff --git a/oss-internship-2020/libpng/examples/example2.cc b/oss-internship-2020/libpng/examples/example2.cc index b791f69..f270ceb 100644 --- a/oss-internship-2020/libpng/examples/example2.cc +++ b/oss-internship-2020/libpng/examples/example2.cc @@ -15,7 +15,7 @@ #include #include -#include "../sandboxed.h" // NOLINT(build/include) +#include "../sandboxed.h" // NOLINT(build/include) #include "../tests/libpng.h" // NOLINT(build/include) struct Data { @@ -65,10 +65,10 @@ absl::Status ReadPng(LibPNGApi& api, LibPNGSapiSandbox& sandbox, absl::StatusOr status_or_png_structp; sapi::v::ConstCStr ver_string_var(PNG_LIBPNG_VER_STRING); + sapi::v::NullPtr null = sapi::v::NullPtr(); SAPI_ASSIGN_OR_RETURN( status_or_png_structp, - api.png_create_read_struct_wrapper(ver_string_var.PtrBefore(), - sapi::v::NullPtr().PtrBoth())); + api.png_create_read_struct_wrapper(ver_string_var.PtrBefore(), &null)); sapi::v::RemotePtr struct_ptr(status_or_png_structp.value()); if (!struct_ptr.GetValue()) { @@ -143,10 +143,10 @@ absl::Status WritePng(LibPNGApi& api, LibPNGSapiSandbox& sandbox, absl::StatusOr status_or_png_structp; sapi::v::ConstCStr ver_string_var(PNG_LIBPNG_VER_STRING); + sapi::v::NullPtr null = sapi::v::NullPtr(); SAPI_ASSIGN_OR_RETURN( status_or_png_structp, - api.png_create_write_struct_wrapper(ver_string_var.PtrBefore(), - sapi::v::NullPtr().PtrBoth())); + api.png_create_write_struct_wrapper(ver_string_var.PtrBefore(), &null)); sapi::v::RemotePtr struct_ptr(status_or_png_structp.value()); if (!struct_ptr.GetValue()) { @@ -176,7 +176,6 @@ absl::Status WritePng(LibPNGApi& api, LibPNGSapiSandbox& sandbox, SAPI_RETURN_IF_ERROR(api.png_write_image_wrapper( &struct_ptr, d.row_pointers->PtrBefore(), d.height, d.rowbytes)); - auto null = sapi::v::NullPtr(); SAPI_RETURN_IF_ERROR(api.png_setjmp(&struct_ptr)); SAPI_RETURN_IF_ERROR(api.png_write_end(&struct_ptr, &null)); @@ -236,4 +235,3 @@ int main(int argc, const char** argv) { return EXIT_SUCCESS; } - diff --git a/oss-internship-2020/libpng/tests/basic_test.cc b/oss-internship-2020/libpng/tests/basic_test.cc index cc22561..24ebf3c 100644 --- a/oss-internship-2020/libpng/tests/basic_test.cc +++ b/oss-internship-2020/libpng/tests/basic_test.cc @@ -64,9 +64,9 @@ TEST(SandboxTest, ReadWrite) { << "image version changed"; sapi::v::Array buffer_(PNG_IMAGE_SIZE(*image.mutable_data())); - status_or_int = api.png_image_finish_read( - image.PtrBoth(), sapi::v::NullPtr().PtrBoth(), buffer_.PtrBoth(), 0, - sapi::v::NullPtr().PtrBoth()); + sapi::v::NullPtr null = sapi::v::NullPtr(); + status_or_int = api.png_image_finish_read(image.PtrBoth(), &null, + buffer_.PtrBoth(), 0, &null); ASSERT_THAT(status_or_int, IsOk()) << "png_image_finish_read fatal error"; ASSERT_THAT(status_or_int.value(), IsTrue()) << "png_image_finish_read failed: " << image.mutable_data()->message; @@ -76,8 +76,7 @@ TEST(SandboxTest, ReadWrite) { << "image format changed"; status_or_int = api.png_image_write_to_file( - image.PtrBoth(), outfile_var.PtrBefore(), 0, buffer_.PtrBoth(), 0, - sapi::v::NullPtr().PtrBoth()); + image.PtrBoth(), outfile_var.PtrBefore(), 0, buffer_.PtrBoth(), 0, &null); ASSERT_THAT(status_or_int, IsOk()) << "png_image_write_to_file fatal error"; ASSERT_THAT(status_or_int.value(), IsTrue()) << "png_image_finish_read failed: " << image.mutable_data()->message; @@ -88,4 +87,3 @@ TEST(SandboxTest, ReadWrite) { } } // namespace - diff --git a/oss-internship-2020/libpng/tests/extended_test.cc b/oss-internship-2020/libpng/tests/extended_test.cc index 78c04ab..fee0942 100644 --- a/oss-internship-2020/libpng/tests/extended_test.cc +++ b/oss-internship-2020/libpng/tests/extended_test.cc @@ -69,9 +69,9 @@ void ReadPng(LibPNGApi& api, LibPNGSapiSandbox& sandbox, ASSERT_THAT(status_or_int.value(), Eq(0)) << infile << " is not a PNG file"; sapi::v::ConstCStr ver_string_var(PNG_LIBPNG_VER_STRING); + sapi::v::NullPtr null = sapi::v::NullPtr(); absl::StatusOr status_or_png_structp = - api.png_create_read_struct_wrapper(ver_string_var.PtrBefore(), - sapi::v::NullPtr().PtrBoth()); + api.png_create_read_struct_wrapper(ver_string_var.PtrBefore(), &null); ASSERT_THAT(status_or_png_structp, IsOk()); sapi::v::RemotePtr struct_ptr(status_or_png_structp.value()); @@ -151,9 +151,9 @@ void WritePng(LibPNGApi& api, LibPNGSapiSandbox& sandbox, ASSERT_THAT(file.GetValue(), NotNull()) << "Could not open " << outfile; sapi::v::ConstCStr ver_string_var(PNG_LIBPNG_VER_STRING); + sapi::v::NullPtr null = sapi::v::NullPtr(); absl::StatusOr status_or_png_structp = - api.png_create_write_struct_wrapper(ver_string_var.PtrBefore(), - sapi::v::NullPtr().PtrBoth()); + api.png_create_write_struct_wrapper(ver_string_var.PtrBefore(), &null); ASSERT_THAT(status_or_png_structp, IsOk()); sapi::v::RemotePtr struct_ptr(status_or_png_structp.value()); @@ -186,7 +186,6 @@ void WritePng(LibPNGApi& api, LibPNGSapiSandbox& sandbox, data.height, data.rowbytes), IsOk()); - auto null = sapi::v::NullPtr(); ASSERT_THAT(api.png_setjmp(&struct_ptr), IsOk()); ASSERT_THAT(api.png_write_end(&struct_ptr, &null), IsOk()); @@ -245,4 +244,3 @@ TEST(SandboxTest, ReadModifyWrite) { } } // namespace - diff --git a/oss-internship-2020/libpng/wrapper/func.cc b/oss-internship-2020/libpng/wrapper/func.cc index c8630b6..cd4d1bf 100644 --- a/oss-internship-2020/libpng/wrapper/func.cc +++ b/oss-internship-2020/libpng/wrapper/func.cc @@ -50,8 +50,3 @@ void png_write_image_wrapper(png_structrp png_ptr, png_bytep image, png_write_image(png_ptr, ptrs); free(ptrs); } - -void png_write_end_wrapper(png_structrp png_ptr) { - png_write_end(png_ptr, NULL); -} - diff --git a/oss-internship-2020/libpng/wrapper/func.h b/oss-internship-2020/libpng/wrapper/func.h index 2233f74..1f8dc91 100644 --- a/oss-internship-2020/libpng/wrapper/func.h +++ b/oss-internship-2020/libpng/wrapper/func.h @@ -18,7 +18,5 @@ void png_read_image_wrapper(png_structrp png_ptr, png_bytep image, size_t height, size_t rowbytes); void png_write_image_wrapper(png_structrp png_ptr, png_bytep image, size_t height, size_t rowbytes); -void png_write_end_wrapper(png_structrp png_ptr); } #endif -