AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

1998.05.29 14:57 "Is Libtiff thread-safe?", by Frank Kim
1998.06.22 19:22 "RE: Is Libtiff thread-safe?", by Frank Kim

1998.06.22 19:22 "RE: Is Libtiff thread-safe?", by Frank Kim

Hi,

I asked this earlier but I did not receive any replies.

I'm using version 3.4 and after quickly scanning the code it seems to me that Libtiff is not thread-safe. Is this true? Are the more recent versions thread-safe?

Here is a code snippet that had me wondering if Libtiff is thread-safe:

_TIFFFindFieldInfo(TIFF* tif, ttag_t tag, TIFFDataType dt)
{
        static const TIFFFieldInfo *last = NULL;
        int i, n;
 
        if (last && last->field_tag == tag &&
            (dt == TIFF_ANY || dt == last->field_type))
                return (last);
        /* NB: if table gets big, use sorted search (e.g. binary search) */
        for (i = 0, n = tif->tif_nfields; i < n; i++) {
                const TIFFFieldInfo* fip = tif->tif_fieldinfo[i];
                if (fip->field_tag == tag &&
                    (dt == TIFF_ANY || fip->field_type == dt))
                        return (last = fip);
        }
        return ((const TIFFFieldInfo *)0);
}

Frank Kim
17 Monsignor Obrien Highway, Cambridge, MA, 02141
frankkim@alum.mit.edu http://cag-www.lcs.mit.edu/~frankkim