@@ -489,8 +489,8 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork {
489
489
data + Buffer::Length (args[6 ]));
490
490
}
491
491
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));
494
494
if (ret)
495
495
ctx->SetDictionary ();
496
496
@@ -516,70 +516,70 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork {
516
516
ctx->SetDictionary ();
517
517
}
518
518
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;
528
528
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 );
532
532
533
- ctx-> flush_ = Z_NO_FLUSH;
533
+ flush_ = Z_NO_FLUSH;
534
534
535
- ctx-> err_ = Z_OK;
535
+ err_ = Z_OK;
536
536
537
- if (ctx-> mode_ == GZIP || ctx-> mode_ == GUNZIP) {
538
- ctx-> windowBits_ += 16 ;
537
+ if (mode_ == GZIP || mode_ == GUNZIP) {
538
+ windowBits_ += 16 ;
539
539
}
540
540
541
- if (ctx-> mode_ == UNZIP) {
542
- ctx-> windowBits_ += 32 ;
541
+ if (mode_ == UNZIP) {
542
+ windowBits_ += 32 ;
543
543
}
544
544
545
- if (ctx-> mode_ == DEFLATERAW || ctx-> mode_ == INFLATERAW) {
546
- ctx-> windowBits_ *= -1 ;
545
+ if (mode_ == DEFLATERAW || mode_ == INFLATERAW) {
546
+ windowBits_ *= -1 ;
547
547
}
548
548
549
- switch (ctx-> mode_ ) {
549
+ switch (mode_) {
550
550
case DEFLATE:
551
551
case GZIP:
552
552
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_);
559
559
break ;
560
560
case INFLATE:
561
561
case GUNZIP:
562
562
case INFLATERAW:
563
563
case UNZIP:
564
- ctx-> err_ = inflateInit2 (&ctx-> strm_ , ctx-> windowBits_ );
564
+ err_ = inflateInit2 (&strm_, windowBits_);
565
565
break ;
566
566
default :
567
567
UNREACHABLE ();
568
568
}
569
569
570
- ctx-> dictionary_ = std::move (dictionary);
570
+ dictionary_ = std::move (dictionary);
571
571
572
- ctx-> write_in_progress_ = false ;
573
- ctx-> init_done_ = true ;
572
+ write_in_progress_ = false ;
573
+ init_done_ = true ;
574
574
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;
578
578
return false ;
579
579
}
580
580
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);
583
583
return true ;
584
584
}
585
585
0 commit comments