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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:40:57+00:00 2026-05-30T20:40:57+00:00

In an API header file I found a strange function declaration: void API_GetParameter(API_SOMESTRUCT param[API_NUM_CONST]);

  • 0

In an API header file I found a strange function declaration:

void API_GetParameter(API_SOMESTRUCT param[API_NUM_CONST]);

where API_NUM_CONST is an enum value and API_SOMESTRUCT is a struct, so my guess is that param is an array of that struct.

The function thus expects an existing data field which it fills or changes. I cannot say what the API function does internally.

Right now, my code looks like this:

API_SOMESTRUCT *param = new API_SOMESTRUCT[API_NUM_CONST];
API_GetParameter(param);
// ... read out param
delete[] param;
param = NULL;

But I suspect this piece of code to be responsible for a heap corruption error I’m recently getting and I’m not sure if my call is correct.


I understand function headers with non-const arrays for parameters that look like this:

void fun(int *arr); // expects a pointer to a non-const int array of arbitrary size...
  • So what is the exact meaning of the API function declaration?
  • Is param being called by value or by reference?
  • And how do I correctly call that function?
  • 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-30T20:40:58+00:00Added an answer on May 30, 2026 at 8:40 pm

    Declaration void f(int x[3]); is the same as void f(int *x); So, the function needs to receive a valid pointer to API_SOMESTRUCT. Otherwise, you can’t know what it is going to do, how many elements it expects, or what it is going to do with them. You have to read the documentation.

    If I had to guess, I would have passed in an array of API_NUM_CONST elements, just allocated on the stack:

    API_SOMESTRUCT param[API_NUM_CONST]
    API_GetParameter(param);
    // use param
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have defined and enum in cython header file api.pxd : ctypedef enum InstructionType:
Here is the problem: Header file (part of a library's API): template <typename IterType>
gcc 4.4.2 c89 I have these defines in our API header file. /* Reason
I'm trying to assemble a header object for an api request. One of the
I'm making an ajax call to a rest API and specified the following header
I've got the following setup. RectangleT class defined in a header file in a
Is there any class provided in the Java standard API that allows file structure
i have been trying to decode an MP3 file to pcm, using ffmpeg API,
I have a header file, that is for a GNU Radio Signal Processing block,
I'm trying to implement PayPal Adaptive Payments API. Into the headers I should include

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.