Subject: Re: bus_space annoyance, API change proposal
To: Ben Harris <bjh21@netbsd.org>
From: Garrett D'Amore <garrett_damore@tadpole.com>
List: tech-kern
Date: 02/16/2006 08:41:25
If your bus_space_handle_t is a structure, and you allocate a new one in
bus_space_subregion(), then how does it get freed?  Most likely you are
leaking those structures right now.  (I've not checked the code tho'.)

    -- Garrett

Ben Harris wrote:
> In article <43F4A2E9.9030705@tadpole.com> you write:
>   
>> Anyway, if someone wants to allocate e.g. a structure from the heap to
>> create a bus_space_handle_t, then there has to be a way to clean it up
>> to avoid leaking the memory.
>>
>> I am therefore proposing a new API be added:
>>
>> void bus_space_subregion_free(bus_space_tag_t, bus_space_handle_t);
>>
>> This frees a bus_space_handle_t allocated by bus_space_subregion().
>>
>> For all existing bus implementations this routine could be #define'd to
>> a nop:
>>
>> #define bus_space_subregion_free(t,h) { }
>>     
>
> On acorn26, I defined bus_space_handle_t to be a small struct, which works,
> and is probably not ludicrously expensive as long as your handles don't need
> many members.
>
>   
>> The bigger issue, as I see it, is changing the callers of
>> bus_space_subregion() so that they free the handle when they need to.
>>     
>
> That seems to me to be rather a lot of work for (as far as I can see) no
> current gain at all.  Why not wait until we find an architecture that
> actually needs it?
>
>   


-- 
Garrett D'Amore, Principal Software Engineer
Tadpole Computer / Computing Technologies Division,
General Dynamics C4 Systems
http://www.tadpolecomputer.com/
Phone: 951 325-2134  Fax: 951 325-2191