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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:25:28+00:00 2026-05-26T01:25:28+00:00

I have a code snippet below, I’m not quite sure what the last line

  • 0

I have a code snippet below, I’m not quite sure what the last line does. More specifically what’s a Bytef[]?

FILE* read_file_handle = fopen(read_filename, "rb");
fseek(read_file_handle, 0, SEEK_END);
size_t no_bytes_to_read = ftell(read_file_handle);
Bytef* read_buffer = new Bytef[no_bytes_to_read];

What is the Bytef[] do? And, if anyone knows, when porting that to PHP, how would I do that?
I thought it might be an array, but such a variable has never been defined and with the new keyword it just wouldn’t make sense.

Can anyone help?

Hosh

EDIT:
Okay so thanks to the user Default it seems to be something defined within zlib.
It’s defined as typedef Byte FAR Bytef; in this file on line 124
Anyone know what the type of Bytef is according to that?
Byte has been defined as a char (typedef unsigned char Byte;) and FAR has been defined: #define FAR
Any help?

  • 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-05-26T01:25:28+00:00Added an answer on May 26, 2026 at 1:25 am

    new Bytef[no_bytes_to_read] simply allocates an array of Bytef objects with a length of no_bytes_to_read.

    If you are porting to PHP, as you say, you may want to review PHP arrays. I’m no PHP expert, but it appears that because arrays are implemented as ordered maps, you cannot preallocate – so there is no direct translation of that line.

    Additionally, as Default pointed out in the link in his comment, a Bytef (which appears to be a part of the zlib library) is just another name for a Byte, which is itself just a typedef for an unsigned char.

    To address your edited question – #define FAR simply creates that symbol. It does nothing in this case – the preprocessor simply strips it. So ultimately Bytef is just another name for an unsigned, 8-bit byte.

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

Sidebar

Related Questions

I am using the code snippet below, however it's not working quite as I
i have below code snippet. It throws the exception at line 3 but query
i have below code snippet. I am not getting how to change the color
I have a table defined (see code snippet below). How can I add a
Does anyone have code snippet for Triple DES algorithm in C ? Thanks
Suppose i have the code snippet as follows : ( clarification purpose/not well formed
i have below code snippet in my legacy project DetachedCriteria subCriteria = DetachedCriteria.forClass(Employee.class); subCriteria.setProjection(Projections.distinct(Property.forName
In the code snippet below - why do I have to give a type
I have created a tab-pane using HAML as shown in my code snippet below
i have a javascript module name SceneModule, see the code snippet below var SceneModule

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.