help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: memory management of all_visible_functions return


From: Chet Ramey
Subject: Re: memory management of all_visible_functions return
Date: Wed, 20 Apr 2022 14:21:36 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.8.1

On 4/20/22 1:28 PM, Robert E. Griffith wrote:
> I am calling all_visible_functions() in my loadable builtin. When I am done
> with the SHELL_VAR** it returns, should I xfree() it?

Yes.

> 
> The reason I am asking is I followed the two places its called in the code
> and I don't see it being freed. They are pretty complicated so I could just
> be missing it but I thought I would ask. I believe that the returned
> variable is allocated in vlist_alloc() in variables.c.

I'll look at the one in the programmable completion code. valgrind doesn't
report any leaks there.

> And while I am asking, what is the concept of invisible variables and
> functions? Do they correspond to something we see in BASH scripts or is it
> an optimization detail?

`Invisible' variables are variables that have been assigned attributes but
not values, so they are technically unset.


-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]