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

The Archive Base Latest Questions

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

gcc 4.7.2 c89 Hello, The function GetCallRef(…) expect a pointer to a buffer for

  • 0
gcc 4.7.2
c89

Hello,

The function GetCallRef(…) expect a pointer to a buffer for this 3rd parameter i.e. call_id is my pointer. However, I don’t know the length of the string that will be returned in the call_id. This call_id will only be used in this function, so will only have local scope so I will be only using the call_id returned in my function.

So my question would be; is it ok to declare a pointer and pass that.

char *call_id = NULL;

Or would be be better to declare an array of a very large size (as I don’t know big is big enough)

char call_id[1024]

The actual function.

if(GetCallRef(crn, GET_CALLID, call_id) == 0) {
    /* use the call id - not used outside of this function */
}

I don’t have the source code for the actual function GetCallRef(...) because it is closed.

I guess the buffer will be better as the function internally may copy directly into that buffer. However, as arrays decay into pointers in function arguments and I am not passing the size as it is not part of this function signature, it will be just 4 bytes in length. How does the function know how big my array is? It cannot.

If I pass a pointer it can assign the address of where the string value is stored i.e. and return that.

call_id = call_reference_id;

All the document says that the buffer should be big enough to store the call id, but it doesn’t say how big it should be.

Many thanks for any advice,

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

    If the documentation says “buffer should be big enough to store the call id”, it means that the function expects the caller to pass a pre-allocated buffer be it on stack or heap.

    The important Q is how much memory should be allocated to the passed buffer?

    The documentation of the function should mention this!
    There is no way to be 100% safe without the function telling you this information.
    Perhaps you need to check some other api which takes similar parameter or check functional spec which documents this.

    Your last option if everything fails is to allocate an array of a big enough size, perhaps 1024 and test the code rigorously.

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

Sidebar

Related Questions

gcc 4.7.2 c89 Hello, I have this function that assigns a pointer to an
gcc 4.6.2 c89 I am passing a pointer to a function. This pointer will
gcc (GCC) 4.6.3 c89 Hello, I am just wondering if this is the best
Possible Duplicate: Should a function have only one return statement? Hello, gcc 4.4.4 c89
gcc 4.7.2 c89 Hello, I am getting the following warning: pointer/integer type mismatch in
gcc 4.7.2 c89 Hello, I have the following function: void module_param_destroy(module_param_t *param) { param
gcc c89 I am getting a stack dump on this line: strcpy(comp->persons->name, Joe); However,
gcc 4.7.2 c89 Hello, I am trying to dereference a pointer to a pointer
gcc (GCC) 4.6.3 20120306 (Red Hat 4.6.3-2) c89 Hello, I am creating a thread
gcc (GCC) 4.6.3 20120306 (Red Hat 4.6.3-2) c89 Hello, I am wondering if I

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.