Memory leaks

I wrote a firmware to read ov7725 camera for cypress FX2LP.

I wrote a code for cypress generic driver on windows -> no leaks
I wrote a code  libusb_win32 for windows -> no leaks
I wrote a code for libusbx-1.0.17 in sync mode for ubuntu -> no leaks

But in async mode with libusbx-1.0.17 -> memory leaks

Each time I read a video frame in async mode with libusbx-1.0.1x  it loose
~100bytes.
You can see this leaks in gnome-system-monitor after some time


my code is:

void cb_response_in(struct libusb_transfer *transfer){
int * completed = transfer->user_data;
*completed  = 1;
}

int get_frame(unsigned char * data, int len ){
int r = 0;
int completed = 0;


        unsigned char tmp[1];

 //Request a video frame to firmware...
        r=libusb_control_transfer( devh,
                                    LIBUSB_REQUEST_TYPE_VENDOR |
LIBUSB_RECIPIENT_DEVICE | LIBUSB_ENDPOINT_OUT,
                                    0xA8,
                                    0x00,
                                    0,
                                    tmp,
                                    0,
                                    500);


        transfer_response_in  = libusb_alloc_transfer(0);

        libusb_fill_bulk_transfer(  transfer_response_in, devh, EP_RESPONSE,
                                    data,
                                    len,
                                    cb_response_in,
                                    &completed,
                                    500);

        r = libusb_submit_transfer(transfer_response_in);
        if ( r != 0){
            printf("libusb_submit_transfer(transfer_response_in); = %d",r);
        }


        struct timeval tv;
        tv.tv_sec  = 0;     // seconds
        tv.tv_usec = 100;   // milliseconds  ( .1 sec)
        while (!completed) {
            r = libusb_handle_events_timeout(NULL, &tv);

            if (r < 0){   // negative values are errors
                   break;
            }
        }

    return r;
}



Anybody can help me ?

thanks
Max.
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to