MCPcopy Create free account
hub / github.com/acl-dev/acl / flush_out

Method flush_out

lib_acl_cpp/src/stdlib/zlib_stream.cpp:435–540  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

433}
434
435bool zlib_stream::flush_out(int (*func)(z_stream*, int),
436 zlib_flush_t flag, string* out)
437{
438 if (func == NULL) {
439 logger_warn("func null, zlib maybe not loaded yet");
440 return false;
441 }
442
443 if (finished_) {
444 return true;
445 }
446
447 if (zstream_->avail_in != 0) {
448 logger_warn("not completed, avali_in not 0");
449 return false;
450 }
451
452 if (zstream_->next_in != NULL) {
453 logger_warn("not completed, next_in not NULL");
454 return false;
455 }
456
457 int dlen, nbuf, ret;
458
459 nbuf = 0;
460 while (true) {
461 nbuf = (int) (out->capacity() - out->length());
462
463 // ��Ҫ��֤����������Ŀ��ÿռ�
464 if (nbuf < BUF_MIN) {
465 nbuf = (int) out->length() + BUF_MIN;
466 out->space(nbuf);
467 }
468
469 dlen = (int) out->length();
470 nbuf = (int) out->capacity() - dlen;
471 if (nbuf < BUF_MIN) {
472 logger_error("no space available, nbuf: %d < %d",
473 nbuf, BUF_MIN);
474 return false;
475 }
476
477 zstream_->next_out = (unsigned char*) out->c_str() + dlen;
478 zstream_->avail_out = (unsigned int) nbuf;
479
480 ret = func(zstream_, flag);
481 if (ret == Z_STREAM_END) {
482 finished_ = true;
483 if (flag != Z_FINISH && func != __inflate) {
484 logger_error("flag=%d, fnc=%p, inflate=%p",
485 flag, func, __inflate);
486 return false;
487 }
488
489 // �޸������������ָ��λ��
490 if (nbuf < (int) zstream_->avail_out) {
491 logger_error("Pos err, nbuf=%d, avail_out=%d",
492 nbuf, (int) zstream_->avail_out);

Callers

nothing calls this directly

Calls 4

capacityMethod · 0.80
lengthMethod · 0.45
spaceMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected