#2265 Memory Leak when merging specifiers?

closed-wont-fix
Maarten Brock
None
other
5
2014-04-03
2014-04-03
CG R
No

Hello,

I were taking a look at the source code and something is really bugging me. When merging specifiers (function mergeDeclSpec() and mergeSpec() at file 'SDCCsymt.c' takes a 'src' and a 'dest' argument), the 'dest' sym_link receives 'src' flags, and it returns 'dest'. What happens with the 'src'? It seems it is never free'd. Also, perhaps it happens with similar functions and operations in the code?

In case I'm wrong, I'm sorry, I was just wondering...

Thank you.

Discussion

  • Maarten Brock
    Maarten Brock
    2014-04-03

    • status: open --> closed-wont-fix
    • assigned_to: Maarten Brock
     
  • Maarten Brock
    Maarten Brock
    2014-04-03

    This happens in many places in SDCC. It is often unclear if a piece of allocated memory can be freed or not. And since SDCC does not run forever, but has a limited lifetime, it was decided to let the OS free all allocated memory on program exit. This is also faster than trying to free all blocks at exit.

    Maarten

     
  • Well, personally, I wouldn't mind if we'd free memory in some places where we know it is safe to do so, but I agree it is not important.
    There also are some places where it is very important to not have memory leaks, in particular dry runs in code generation come to mind. And having less memory leaks in general should make it easier to e.g. use valgrind to look for memory leaks that matter.

    Philipp

     
    Last edit: Philipp Klaus Krause 2014-04-03