lcompilers / lpython

Python compiler
https://lpython.org/
Other
1.37k stars 157 forks source link

Introducing basic_free_stack_if_not_null #2643

Open anutosh491 opened 3 months ago

anutosh491 commented 3 months ago

Addressing https://github.com/lcompilers/lpython/issues/2614#issuecomment-2035025925

We have been using the basic_free_stack out of symengine's C wrapper untill now. But before freeing out variables we need to check if they have been stack allocated previously. Hence this PR aims to replace every basic_free_stack call with

    if (var != NULL) {
        basic_free_stack(var);
    }
anutosh491 commented 2 months ago

I tried approach 1 & 2 as mentioned here (https://github.com/lcompilers/lpython/issues/2614#issuecomment-2009981787) but haven't been able to address the example in consideration fully. cc @Thirumalai-Shaktivel could you try helping me out here ?

certik commented 2 months ago

@anutosh491 what is the status here --- can you describe what the problem is?

Are you trying to address this comment: https://github.com/lcompilers/lpython/issues/2614#issuecomment-2035025925 ?