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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:59:31+00:00 2026-06-15T21:59:31+00:00

Just to situate the context: it’s about a string pool, meaning a hash table

  • 0

Just to situate the context: it’s about a string pool, meaning a hash table with string keys (actually special strings that know their length, but I guess this detail is irrelevant here). The point is the resizing of the array of lists (used as table buckets) when the pool needs to grow. But –this is the core detail– cells containing string actually in an array of cells, instead of being spread out in all corners of memory [1]. Thus, I don’t need the lists anymore, they’re just outdated stuff. So:

  1. Is there a variant of realloc that “zeroes” the memory area like calloc?
    I need that here because the items are not only pointers, but lists heads: the issue is to ensure an empty list is/shows as NULL. Else, is the best solution just to memset(p, size, 0);

  2. Is there a variant of realloc that does not copy if ever there is not enough space to grow on place, but instead just allocates like alloc? The issue here is that I don’t need the data anymore, since strings need to be re-distributed in lists according to new modulo. Else, what is the best choice?

    • use realloc
    • (free &) use alloc
    • (free &) use calloc

Is this right in any case: realloc tries to alloc more space on place, else allocates elsewhere and silently copies? If yes, then maybe a problem is there are (at least) three use cases requiring different actions –in both cases where there is or there is not enough space on place– but a single func with no option at all:

  • I need more place for these data and more to come (standard).
  • I need more place, but the data are garbage from now on.
  • I need more space and the area to be “zeroed”.

What is the best option for me? What do you think else? Where can I find more reflexions or info on the topic?

Is there a reason why alloc has a different interface from calloc and realloc? (I mean specifying total-size vs single-size & count)

[1] The point was originally to make ordered sets & maps; for a string pool it is not needed but does not bother. Instead, it makes code clearer and provides locality of reference.

  • 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-15T21:59:32+00:00Added an answer on June 15, 2026 at 9:59 pm

    Is there a variant of realloc that “zeroes” the memory area like
    calloc? I need that here because the items are not only pointers, but
    lists heads: the issue is to ensure an empty list is/shows as NULL.
    Else, is the best solution just to memset(p, size, 0);

    If you’re coding strictly for the standard, you’re stuck with memset. At least this one is easy to work around.

    If you’ve got some platform-specific leeway, some of them do have a recalloc function.

    Is there a variant of realloc that does not copy if ever there is not
    enough space to grow on place, but instead just allocates like alloc?
    The issue here is that I don’t need the data anymore, since strings
    need to be re-distributed in lists according to new modulo. Else, what
    is the best choice?

    Again no, unfortunately.

    There is a proposal for C1X which adds both of these features (among others), but for now you’re stuck with realloc‘s current behavior.

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

Sidebar

Related Questions

Just a silly question that just cant figure out. Ive been working on iPad
I have this SQL Server Agent, that creates a backup table, doing this: DECLARE
Just to be sure, can experts confirm that java.util.concurrent.locks.Lock and Doug Lea's original Sync
Just had a question regarding the UILabel class. I know that the UITextField control
Just wanted to inquire about the optimisation of file size of the FLA file..
Let's imagine we have some script 'm12' (I've just invented this name) that runs
Just learning C++, encountered an issue that i'm not really sure why the following
Just want to mention that I am really a newbie in API development (concepts,
Just wondering. I have a page in Jquery Mobile which uses a popup that
Just started converting to MVC from classic ASP and wondering about best practice for

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.