Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7769773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:14:29+00:00 2026-06-01T16:14:29+00:00

def deflate(string, level) z = Zlib::Deflate.new(level) dst = z.deflate(string, Zlib::NO_FLUSH) z.close return dst end

  • 0
def deflate(string, level)
  z = Zlib::Deflate.new(level)
  dst = z.deflate(string, Zlib::NO_FLUSH)
  z.close
  return dst
end

def inflate(string)
  zstream = Zlib::Inflate.new
  buf = zstream.inflate(string)
  zstream.finish
  zstream.close
  return buf
end

a = deflate("asasasas",6)
p a
p inflate(a)

Gives me a buffer error on line

  zstream.finish

Why is that? Ruby 1.8.7 I believe.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T16:14:30+00:00Added an answer on June 1, 2026 at 4:14 pm

    The documentation on deflate says:

    Normally the parameter flush is set to Z_NO_FLUSH, which allows
    deflate to decide how much data to accumulate before producing output,
    in order to maximize compression.

    By using Zlib::NO_FLUSH the returned value is not the entire deflated stream. Use Zlib::FINISH instead.

    The functions you’ve written are the ones provided in the Zlib::Deflate / Zlib::Inflate documentation. You could replace all the code you’ve written with:

    a = Zlib::Deflate.deflate("asasasas", 6)
    p a
    p Zlib::Inflate.inflate(a)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

def remove_section(alist, start, end): Return a copy of alist removing the section from start
def new @user = User.find(session[:this_user]) @message = Message.new @people= People.order(is_active DESC, first_name, last_name) end
def binarysearch(a, b, tofind, stringarray) k=(a+b)/2 if a==b return nil end if (stringarray[k]).include? tofind
I'm trying to deflate and inflate a text file using zlib-1.2.7 with VC++2010. I
def download_if_dne(href, filename): if os.path.isfile(filename): # print 'already downloaded:', href return False else: if
def update @album = Album.find(params[:id]) if @album.update_attributes(params[:album]) redirect_to(:action=>'list') else render(:action=>'edit') end end A Rails
def test_method [a, b, c].map {|i| yield(i) } end If I call test_method like
def self.get(server) return unless server server = server.to_s if klass = @handlers[server] obj =
def any? if block_given? method_missing(:any?) { |*block_args| yield(*block_args) } else !empty? end end In
def record return unless @supported klasses = profile_options[:formats].map { |f| RubyProf.const_get(#{f.to_s.camelize}Printer) }.compact klasses.each do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.