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

  • Home
  • SEARCH
  • 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 964649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:51:49+00:00 2026-05-16T01:51:49+00:00

I have a function which reallocs a pointer given as an argument to a

  • 0

I have a function which reallocs a pointer given as an argument to a new size. Now, the problem is that – according to the man page – realloc needs a pointer which has been returned by malloc or calloc before.

How can I make sure that the caller passes a pointer that meets those requirements?
There seem to be no build-in C mechanics (like type qualifiers or something) to do so.

Now, before I restructure my API (as I consider the function as it is now not to be robust enough) – can you please verify that I haven’t missed something?

Thanks in advance.

Edit:
One solution would obviously be to malloc in the function. The problem with that is that the caller does not “see” the allocation. Thus I would need to explictly say in the docs that he has to free the pointer. That’s even worse than to expect them to provide a malloc’d pointer (which would imply that the caller has to free it).

What I really want is something that blocks abuse at compile time. That, and a pony. 😉

  • 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-16T01:51:49+00:00Added an answer on May 16, 2026 at 1:51 am

    How can I make sure that the caller passes a pointer that meets those requirements?

    Documentation.

    Define the API.

    If the person writing the caller refuses to follow the API, things crash. They refused to play by your rules and things crashed. What did they expect?

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

Sidebar

Ask A Question

Stats

  • Questions 491k
  • Answers 491k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Take a look at linked servers. http://technet.microsoft.com/en-us/library/ms188279.aspx May 16, 2026 at 10:06 am
  • Editorial Team
    Editorial Team added an answer I managed to reproduce this issue. Consider the following. Assume… May 16, 2026 at 10:06 am
  • Editorial Team
    Editorial Team added an answer IID_PPV_ARGS Macro Used to retrieve an interface pointer, supplying the… May 16, 2026 at 10:06 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have an oracle function which is given below. when I run this in
I have a function which is called multiple times during the program's execution. In
I have a simple C program which has a pointer to a character array.
I'm trying to create a function which takes an array as an argument, adds
I have function which takes in an parameter of a class called Triple, and
I have a function which returns a referenced value by default – however, the
I have a function which receives a string parameter, I need to convert this
i have a function called ViewComments() which retrieve contents from database using SQL commands
I have thousands of function wrappers which inside actually perform a similar logic like:
I have the following jquery which animates on hover: $('#footerNetwork').hover(function(){ $('#popupNetwork').animate({top:'-62px'},{queue:true,duration:500}); }, function(){ $('#popupNetwork').animate({top:'30px'},{queue:true,duration:500});

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.