Skip to content

Commit

Permalink
fix edgeworker clashing with zlib function
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Aug 6, 2024
1 parent 93fdcb8 commit 577d544
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
11 changes: 2 additions & 9 deletions src/workerd/api/node/zlib-util.c++
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,9 @@

namespace workerd::api::node {

namespace {
// This function is required to avoid function name clash.
uint32_t crc32Impl(uint32_t value, unsigned char* bytes, size_t size) {
uint32_t ZlibUtil::crc32Sync(kj::Array<kj::byte> data, uint32_t value) {
// Note: Bytef is defined in zlib.h
return crc32(value, reinterpret_cast<const Bytef*>(bytes), size);
}
} // namespace

uint32_t ZlibUtil::crc32(kj::Array<kj::byte> data, uint32_t value) {
return crc32Impl(value, data.begin(), data.size());
return crc32(value, reinterpret_cast<const Bytef*>(data.begin()), data.size());
}

} // namespace workerd::api::node
4 changes: 2 additions & 2 deletions src/workerd/api/node/zlib-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ class ZlibUtil final : public jsg::Object {
ZlibUtil() = default;
ZlibUtil(jsg::Lock&, const jsg::Url&) {}

uint32_t crc32(kj::Array<kj::byte> data, uint32_t value);
uint32_t crc32Sync(kj::Array<kj::byte> data, uint32_t value);

JSG_RESOURCE_TYPE(ZlibUtil) {
JSG_METHOD(crc32);
JSG_METHOD_NAMED(crc32, crc32Sync);
}
};

Expand Down

0 comments on commit 577d544

Please sign in to comment.