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 9134955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:45:31+00:00 2026-06-17T08:45:31+00:00

In zlib 1.2.7, file inffast.c, line 320, there is a statement that I do

  • 0

In zlib 1.2.7, file inffast.c, line 320, there is a statement that I do not understand:

strm->avail_out = (unsigned)(out < end ?
                             257 + (end - out) : 257 - (out - end));

Variables end and out are two pointers into the output buffer.
This statement makes an effort to compute end - out when end > out and out - end when out >= end, but I do not see why it might want to do that. It seems to me that the end result is the same, that is, the line might as well have been written:

strm->avail_out = 257 + (end - out);

The difference of two pointers has a signed integral type, ptrdiff_t (C99 6.5.6:9), and 257 has type int. The addition takes place in the type of higher rank between these two, and I do not see what the ternary operator could possibly be guarding against.

  • 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-17T08:45:32+00:00Added an answer on June 17, 2026 at 8:45 am

    Your observation is correct for C99 as well as C89/C90.

    That line of code was written ten years ago. At this point my memory permits me only to be able to claim paranoia as the excuse. Apparently I was concerned that in some compilers the result of subtracting two pointers might be unsigned. I do not recall the origin of that concern, or if it had any basis at all.

    As for the change history, that line of code was born from the brow of Zeus as you see it today. It has not been changed since it was written.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I downloaded zlib.NET and there's a file that I must import,its named zlib.net.dll. My
I'm trying to use Zlib::Deflate.deflate on a massive file (4 gigs). There are obvious
I need iostream wrapper for zlib that allow to append data into end of
I have a Zip archive with a large (important) file that will not extract.
Here is my code which checks if the file exists : #include<stdio.h> #include<zlib.h> #include<unistd.h>
I am trying to compile a code that uses Boost's zlib wrappers. However, no
Is there some magic required to obtain a zlib sync flush when using boost::iostreams::zlib_compressor
Can anyone tell me the difference between using mod_deflate and zlib output_compression? I understand
I have a .gz file that contains an XML document. Does anyone know how
I've created a servlet that changes the binaries of a SWF file and output

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.