Logo Search packages:      
Sourcecode: zbar version File versions  Download package

void zbar_image_free_data ( zbar_image_t image  )  [inline]

built-in cleanup handler. passes the image data buffer to free()

Definition at line 107 of file image.c.

References zbar_image_create(), and zbar_image_free_data().

Referenced by zbar_image_convert_resize(), zbar_image_free_data(), and zbar_image_set_data().

{
    if(!img)
        return;
    if(img->src) {
        /* replace video image w/new copy */
        assert(img->refcnt); /* FIXME needs lock */
        zbar_image_t *newimg = zbar_image_create();
        memcpy(newimg, img, sizeof(zbar_image_t));
        /* recycle video image */
        newimg->cleanup(newimg);
        /* detach old image from src */
        img->cleanup = NULL;
        img->src = NULL;
        img->srcidx = -1;
    }
    else if(img->cleanup && img->data) {
        if(img->cleanup != zbar_image_free_data) {
            /* using function address to detect this case is a bad idea;
             * windows link libraries add an extra layer of indirection...
             * this works around that problem (bug #2796277)
             */
            zbar_image_cleanup_handler_t *cleanup = img->cleanup;
            img->cleanup = zbar_image_free_data;
            cleanup(img);
        }
        else
            free((void*)img->data);
    }
    img->data = NULL;
}


Generated by  Doxygen 1.6.0   Back to index