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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:54:24+00:00 2026-06-01T10:54:24+00:00

this error is always fired, when i’m try to free my allocated struct the

  • 0

this error is always fired, when i’m try to free my allocated struct the second time, which it shouldn’t, because the struct is set to NULL after i’m freeing it.

here’s my struct with no real pointer inside it:

 typedef struct{
        int frame; 
        double timestamp; 
        int identifier; 
        int state; 
        int unknown1; 
        int unknown2; 
        mtVector normalized;
        float size; 
        int unknown3;
        float angle; 
        float majorAxis;
        float minorAxis;
        mtVector unknown4; 
        int unknown5[2]; 
        float unknown6; 
    }Touch;

the barebone main function:

int main(){
    Touch *myTouch = NULL;
    int inputCounter = 0;
    //whenever  a touch is recognized:
    ...
    myTouch = (Touch*)realloc(myTouch,sizeof(Touch)*(inputCounter++));
    ...
    // everything works fine until:
    freeTouch(myTouch);
}

void freeTouch(Touch *f){
    if(f != NULL){
        free(f);
        f = NULL;
    }
}

anybody got an idea?

  • 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-01T10:54:26+00:00Added an answer on June 1, 2026 at 10:54 am

    f is a local variable. free(f) will affect the allocated memory, but f = NULL has no impact on myTouch in freeTouch(myTouch);.

    Try

    void freeTouch(Touch **f){
        if(*f != NULL){
            free(*f);
            *f = NULL;
        }
    }
    

    instead and use freeTouch(&myTouch).

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

Sidebar

Related Questions

I always get this error when trying to compile my file with Boost::GIL PNG
I always got this error guys on my site.Anybody got a solution. Stacktrace at
I am trying to deserialize a stream but I always get this error End
I can't seem to compile ironruby in ruby 1.8.7. I always get this error:
This is a compiler error (slightly changed for readability). This one always puzzled me.
I'm trying to get this running: JAXB interface But I always get the error
This error just started popping up all over our site. Permission denied to call
This error seems to just pop up now and again. It is not restricted
This error message appears on a colleague's machine when he tries to launch a
I'm trying to compile this but I get the error error: ‘setioflags’ was not

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.