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

The Archive Base Latest Questions

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

I am trying to pass a variable by reference into a void pointer in

  • 0

I am trying to pass a variable by reference into a void pointer in order to update the original value. When I try it, the old value is never updated. Any help will be appreciated.
gst_filter_chain is like the main function (Gstreamer)

void update_value(void *oldValue, void *newValue)
{
    oldValue = newValue;
}

void update_struct(myStruct *oldStruct, myStruct newStruct)
{
    update_value((void *)&oldStruct->a, (void *)&newStruct.a)
}

static GstFlowReturn
gst_filter_chain (GstPad * pad, GstBuffer * buf)
{
    GstFilter *filter= GST_FILTER (gst_pad_get_parent (pad));
    myStruct temp_data;

    int buf_size = GST_BUFFER_SIZE(buf);     
    if(buf_size > 1) //if buffer is not empty
    {
        if(!filter->is_init)
        {
            memcpy(&filter->data, GST_BUFFER_DATA(buf), sizeof(myStruct));
            filter->is_init = TRUE;
        }
        else
        {
            memcpy(&temp_data, GST_BUFFER_DATA(buf), sizeof(myStruct));
            update_struct(&filter->data, temp_data);
        }
    }   


    gst_buffer_unref(buf);
    return GST_FLOW_OK;
}
  • 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-15T09:59:54+00:00Added an answer on June 15, 2026 at 9:59 am
    void update_value(void *oldValue, void *newValue)
    {
        oldValue = newValue;
    }
    

    In this snippet, you are only updating the pointer variable, not the value it points to.
    You have to de-reference the pointer to access the actual data. If you want a really generic setter solution, you could use memcpy, but you’d need to pass to update_value a size parameter, to tell memcpy what’s the size of the datatype pointed by oldValue and newValue.

    void update_value(void *oldValue, void *newValue, size_t dataSize)
    {
        memcpy(oldValue, newValue, dataSize);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to pass a reference to a variable and then update the contents
I am trying to pass a php variable into a java script window.location that
i am trying to pass in a selector into the ID variable but this
Quick question, I'm trying to pass a value to a variable and then run
I'm trying to pass a variable by reference to a different class, but I
Possible Duplicate: Difference between pointer variable and reference variable in C++ suppose I'm trying
I'm trying to pass the value of a dropdownlist to a session variable, and
I'm trying to pass document.write as a reference to a variable: Example: var f
I'm trying to use a string as a reference to a variable to pass
So I'm basically trying to pass the <link> and <script> tags into my original

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.