Skip to content

Commit d72867e

Browse files
addaleaxtargos
authored andcommitted
src: make ZCtx::Init() non-static
PR-URL: #23019 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gus Caplan <[email protected]>
1 parent 56b1a3c commit d72867e

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

src/node_zlib.cc

+38-38
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,8 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork {
489489
data + Buffer::Length(args[6]));
490490
}
491491

492-
bool ret = Init(ctx, level, windowBits, memLevel, strategy, write_result,
493-
write_js_callback, std::move(dictionary));
492+
bool ret = ctx->Init(level, windowBits, memLevel, strategy, write_result,
493+
write_js_callback, std::move(dictionary));
494494
if (ret)
495495
ctx->SetDictionary();
496496

@@ -516,70 +516,70 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork {
516516
ctx->SetDictionary();
517517
}
518518

519-
static bool Init(ZCtx* ctx, int level, int windowBits, int memLevel,
520-
int strategy, uint32_t* write_result,
521-
Local<Function> write_js_callback,
522-
std::vector<unsigned char>&& dictionary) {
523-
AllocScope alloc_scope(ctx);
524-
ctx->level_ = level;
525-
ctx->windowBits_ = windowBits;
526-
ctx->memLevel_ = memLevel;
527-
ctx->strategy_ = strategy;
519+
bool Init(int level, int windowBits, int memLevel,
520+
int strategy, uint32_t* write_result,
521+
Local<Function> write_js_callback,
522+
std::vector<unsigned char>&& dictionary) {
523+
AllocScope alloc_scope(this);
524+
level_ = level;
525+
windowBits_ = windowBits;
526+
memLevel_ = memLevel;
527+
strategy_ = strategy;
528528

529-
ctx->strm_.zalloc = AllocForZlib;
530-
ctx->strm_.zfree = FreeForZlib;
531-
ctx->strm_.opaque = static_cast<void*>(ctx);
529+
strm_.zalloc = AllocForZlib;
530+
strm_.zfree = FreeForZlib;
531+
strm_.opaque = static_cast<void*>(this);
532532

533-
ctx->flush_ = Z_NO_FLUSH;
533+
flush_ = Z_NO_FLUSH;
534534

535-
ctx->err_ = Z_OK;
535+
err_ = Z_OK;
536536

537-
if (ctx->mode_ == GZIP || ctx->mode_ == GUNZIP) {
538-
ctx->windowBits_ += 16;
537+
if (mode_ == GZIP || mode_ == GUNZIP) {
538+
windowBits_ += 16;
539539
}
540540

541-
if (ctx->mode_ == UNZIP) {
542-
ctx->windowBits_ += 32;
541+
if (mode_ == UNZIP) {
542+
windowBits_ += 32;
543543
}
544544

545-
if (ctx->mode_ == DEFLATERAW || ctx->mode_ == INFLATERAW) {
546-
ctx->windowBits_ *= -1;
545+
if (mode_ == DEFLATERAW || mode_ == INFLATERAW) {
546+
windowBits_ *= -1;
547547
}
548548

549-
switch (ctx->mode_) {
549+
switch (mode_) {
550550
case DEFLATE:
551551
case GZIP:
552552
case DEFLATERAW:
553-
ctx->err_ = deflateInit2(&ctx->strm_,
554-
ctx->level_,
555-
Z_DEFLATED,
556-
ctx->windowBits_,
557-
ctx->memLevel_,
558-
ctx->strategy_);
553+
err_ = deflateInit2(&strm_,
554+
level_,
555+
Z_DEFLATED,
556+
windowBits_,
557+
memLevel_,
558+
strategy_);
559559
break;
560560
case INFLATE:
561561
case GUNZIP:
562562
case INFLATERAW:
563563
case UNZIP:
564-
ctx->err_ = inflateInit2(&ctx->strm_, ctx->windowBits_);
564+
err_ = inflateInit2(&strm_, windowBits_);
565565
break;
566566
default:
567567
UNREACHABLE();
568568
}
569569

570-
ctx->dictionary_ = std::move(dictionary);
570+
dictionary_ = std::move(dictionary);
571571

572-
ctx->write_in_progress_ = false;
573-
ctx->init_done_ = true;
572+
write_in_progress_ = false;
573+
init_done_ = true;
574574

575-
if (ctx->err_ != Z_OK) {
576-
ctx->dictionary_.clear();
577-
ctx->mode_ = NONE;
575+
if (err_ != Z_OK) {
576+
dictionary_.clear();
577+
mode_ = NONE;
578578
return false;
579579
}
580580

581-
ctx->write_result_ = write_result;
582-
ctx->write_js_callback_.Reset(ctx->env()->isolate(), write_js_callback);
581+
write_result_ = write_result;
582+
write_js_callback_.Reset(env()->isolate(), write_js_callback);
583583
return true;
584584
}
585585

0 commit comments

Comments
 (0)