libftdi Archives

Subject: RE: libftdi-1.0: Reduce memory leaks

From: "Michael Plante" <michael.plante@xxxxxxxxx>
To: <libftdi@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 7 Jun 2010 17:16:40 -0500
Uwe Bonnes wrote:
>> >>>>> "Michael" == Michael Plante <michael.plante@xxxxxxxxx> writes:
>>     Michael> I admit I haven't been looking at libftdi-1.0 much yet, but
>>     Michael> does libftdi-1 not yet support non-default libusb contexts
>>     Michael> (i.e., libusb_context * != NULL)?
>>
>> Yes.
>>
>> But libftdi doesn't yet hold the context. Why do you need the context?

Because I have multiple FTDI chips, each associated with one plugin thread,
and each associated with one libftdi-0.1 context.  The devices and threads
are essentially independent, and I can't have them stepping on one another's
settings in the context.  That, and if I can keep it clean by giving each
its own context, I run less risk of running into synchronization bugs, if
any remain.  Plus, the various linked lists in libusb are traversed more
quickly.  Etc.

In short, I generally think that if people are able to use separate libusb
contexts, they should, and that the default context should only be used in 2
cases:

1) quick and dirty test apps

2) apps that only talk to one usb device (ftdi or otherwise)

IMO...



>> If the context is needed, we must add the context to libftdi context and
>> fill and use the libusb context in the appropriate calls.

Yes, I agree.  However, if it's easier, I could fill the member in manually
like I have to do with some (unrelated) members in the libftdi-0.1 context.
The context could default to NULL in ftdi_init().  (I am using the C API)




>>     Michael> (That will be a stumbling
>>     Michael> point before I can upgrade from 0.1...
>>
>> Should I prepare a patch?

You could, but you don't need to.  When I get around to upgrading, I can do
it.  It will be at least a couple more months before I'm ready.  I just
happened to see the "NULL" in your patch and thought to ask about it.

Thank you,
Michael


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread