Re: free seems not work

new topic     » goto parent     » topic index » view thread      » older message » newer message

The problem is that you declare the sequence ptr_liste in the procedure UnCycleComplet. It is LOCAL to that procedure. Then you pass it to the allocator, which makes its OWN LOCAL COPY. After allocation, the ptr_liste in UnCycleComplet is still just a string of zeros, which is what you are then passing to the free function. You can fix it by making your allocator a function that passes the sequence back instead of a procedure:

function allocate_bcl(sequence ptr_liste)                          --  
    for j=1 to BOUCLE do                                            --  
        ptr_liste[j]=allocate(10000)                                --  
    end for  
    return ptr_liste                                                  --  
end function 

and then also:

procedure UnCycleComplet()                                          --  
    sequence ptr_liste                                              --  
    ptr_liste = repeat(0,BOUCLE)                                    --  
    for i=1 to NOMBRE_CYCLE do                                      --  
        ptr_liste = allocate_bcl(ptr_liste)                                     --  
        free_bcl(ptr_liste)                                         --  
    end for                                                         --  
end procedure    

Understand the difference?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu