48c48
< static const TIFFField
---
> static const TIFFFieldInfo
196c196
< static const TIFFField
---
> static const TIFFFieldInfo
279c279
< 			TIFFField *fld = tif->tif_fieldinfo[i];
---
> 			TIFFFieldInfo *fld = tif->tif_fieldinfo[i];
290c290
< 	if (!_TIFFMergeField(tif, infoarray->fieldinfo, infoarray->used))
---
> 	if (!_TIFFMergeFieldInfo(tif, infoarray->fieldinfo, infoarray->used))
300,301c300,301
< 	const TIFFField* ta = *(const TIFFField**) a;
< 	const TIFFField* tb = *(const TIFFField**) b;
---
> 	const TIFFFieldInfo* ta = *(const TIFFFieldInfo**) a;
> 	const TIFFFieldInfo* tb = *(const TIFFFieldInfo**) b;
313,314c313,314
< 	const TIFFField* ta = *(const TIFFField**) a;
< 	const TIFFField* tb = *(const TIFFField**) b;
---
> 	const TIFFFieldInfo* ta = *(const TIFFFieldInfo**) a;
> 	const TIFFFieldInfo* tb = *(const TIFFFieldInfo**) b;
334,420d333
< static TIFFSetGetFieldType
< _TIFFSetGetType(TIFFDataType type)
< {
< 	switch (type)
< 	{
< 		case TIFF_BYTE:
< 		case TIFF_UNDEFINED:
< 			return TIFF_SETGET_C32_UINT8;
< 		case TIFF_ASCII:
< 			return TIFF_SETGET_C32_ASCII;
< 		case TIFF_SHORT:
< 			return TIFF_SETGET_C32_UINT16;
< 		case TIFF_LONG:
< 			return TIFF_SETGET_C32_UINT32;
< 		case TIFF_RATIONAL:
< 		case TIFF_SRATIONAL:
< 		case TIFF_FLOAT:
< 			return TIFF_SETGET_C32_FLOAT;
< 		case TIFF_SBYTE:
< 			return TIFF_SETGET_C32_SINT8;
< 		case TIFF_SSHORT:
< 			return TIFF_SETGET_C32_SINT16;
< 		case TIFF_SLONG:
< 			return TIFF_SETGET_C32_SINT32;
< 		case TIFF_DOUBLE:
< 			return TIFF_SETGET_C32_DOUBLE;
< 		case TIFF_IFD:
< 		case TIFF_IFD8:
< 			return TIFF_SETGET_C32_IFD8;
< 		case TIFF_LONG8:
< 			return TIFF_SETGET_C32_UINT64;
< 		case TIFF_SLONG8:
< 			return TIFF_SETGET_C32_SINT64;
< 		default:
< 			return TIFF_SETGET_UNDEFINED;
< 	}
< }
< 
< int
< _TIFFMergeField(TIFF* tif, const TIFFField info[], uint32 n)
< {
< 	const char module[] = "_TIFFMergeFieldInfo";
< 	const char reason[] = "for field info array";
< 	TIFFField** tp;
< 	uint32 i;
< 
< 	for (i = 0; i < n; i++) {
< 		const TIFFFieldInfo *fip =
< 			_TIFFFindFieldInfo(tif, info[i].field_tag, TIFF_ANY);
< 		if (fip) {
< 			TIFFErrorExt(tif->tif_clientdata, module,
< 			"Field with tag %lu is already registered as \"%s\"",
< 				     (unsigned int) info[i].field_tag,
< 				     fip->field_name);
< 			return 0;
< 		}
< 	}
< 
<         tif->tif_foundfield = NULL;
< 
< 	if (tif->tif_nfields > 0) {
< 		tif->tif_fieldinfo = (TIFFField**)
< 			_TIFFCheckRealloc(tif, tif->tif_fieldinfo,
< 					  (tif->tif_nfields + n),
< 					  sizeof(TIFFField *), reason);
< 	} else {
< 		tif->tif_fieldinfo = (TIFFField **)
< 			_TIFFCheckMalloc(tif, n, sizeof(TIFFField *),
< 					 reason);
< 	}
< 	if (!tif->tif_fieldinfo) {
< 		TIFFErrorExt(tif->tif_clientdata, module,
< 			     "Failed to allocate field info array");
< 		return 0;
< 	}
< 	tp = tif->tif_fieldinfo + tif->tif_nfields;
< 	for (i = 0; i < n; i++)
< 		*tp++ = (TIFFField *) (info + i);	/* XXX */
< 
<         /* Sort the field info by tag number */
< 	qsort(tif->tif_fieldinfo, tif->tif_nfields += n,
< 	      sizeof(TIFFField *), tagCompare);
< 
< 	return n;
< }
< 
< 	
426c339
< 	TIFFField** tp;
---
> 	TIFFFieldInfo** tp;
444c357
< 		tif->tif_fieldinfo = (TIFFField**)
---
> 		tif->tif_fieldinfo = (TIFFFieldInfo**)
447c360
< 					  sizeof(TIFFField*), reason);
---
> 					  sizeof (TIFFFieldInfo*), reason);
449,450c362,363
< 		tif->tif_fieldinfo = (TIFFField**)
< 			_TIFFCheckMalloc(tif, n, sizeof(TIFFField*),
---
> 		tif->tif_fieldinfo = (TIFFFieldInfo**)
> 			_TIFFCheckMalloc(tif, n, sizeof (TIFFFieldInfo*),
459,474c372,373
< 	for (i = 0; i < n; i++) {
< 		/* NB: backward compatibility stuff */
< 		(*tp)->field_tag = info[i].field_tag;
< 		(*tp)->field_readcount = info[i].field_readcount;
< 		(*tp)->field_writecount = info[i].field_writecount;
< 		(*tp)->field_type = info[i].field_type;
< 		(*tp)->reserved = 0;
< 		(*tp)->set_field_type = _TIFFSetGetType(info[i].field_type);
< 		(*tp)->get_field_type = _TIFFSetGetType(info[i].field_type);
< 		(*tp)->field_bit = info[i].field_bit;
< 		(*tp)->field_oktochange = info[i].field_oktochange;
< 		(*tp)->field_passcount = info[i].field_passcount;
< 		(*tp)->field_name = info[i].field_name;
< 		(*tp)->field_subfields = NULL;
< 		tp++;
< 	}
---
> 	for (i = 0; i < n; i++)
> 		*tp++ = (TIFFFieldInfo*) (info + i);	/* XXX */
478c377
< 	      sizeof(TIFFField*), tagCompare);
---
> 	      sizeof (TIFFFieldInfo*), tagCompare);
490c389
< 		const TIFFField* fip = tif->tif_fieldinfo[i];
---
> 		const TIFFFieldInfo* fip = tif->tif_fieldinfo[i];
575,600d473
< const TIFFField*
< _TIFFFindField(TIFF* tif, uint32 tag, TIFFDataType dt)
< {
< 	TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL, NULL};
< 	TIFFField* pkey = &key;
< 	const TIFFField **ret;
< 	if (tif->tif_foundfield && tif->tif_foundfield->field_tag == tag &&
< 	    (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type))
< 		return tif->tif_foundfield;
< 
< 	/* If we are invoked with no field information, then just return. */
< 	if ( !tif->tif_fieldinfo ) {
< 		return NULL;
< 	}
< 
< 	/* NB: use sorted search (e.g. binary search) */
< 
< 	key.field_tag = tag;
< 	key.field_type = dt;
< 
< 	ret = (const TIFFField **) bsearch(&pkey, tif->tif_fieldinfo,
< 					   tif->tif_nfields,
< 					   sizeof(TIFFField *), tagCompare);
< 	return tif->tif_foundfield = (ret ? *ret : NULL);
< }
< 
604d476
< #if 0
628,656d499
< #endif
< 	return NULL;
< }
< 
< const TIFFField*
< _TIFFFindFieldByName(TIFF* tif, const char *field_name, TIFFDataType dt)
< {
< 	TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL, NULL};
< 	TIFFField* pkey = &key;
< 	const TIFFField **ret;
< 	if (tif->tif_foundfield
< 	    && streq(tif->tif_foundfield->field_name, field_name)
< 	    && (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type))
< 		return (tif->tif_foundfield);
< 
< 	/* If we are invoked with no field information, then just return. */
< 	if ( !tif->tif_fieldinfo ) {
< 		return NULL;
< 	}
< 
< 	/* NB: use sorted search (e.g. binary search) */
< 
< 	key.field_name = (char *)field_name;
< 	key.field_type = dt;
< 
< 	ret = (const TIFFField **) lfind(&pkey, tif->tif_fieldinfo,
< 					 &tif->tif_nfields,
< 					 sizeof(TIFFField *), tagNameCompare);
< 	return tif->tif_foundfield = (ret ? *ret : NULL);
662d504
< #if 0
687,688d528
< #endif
< 	return NULL;
719,720c559,560
< const TIFFField*
< _TIFFFindOrRegisterFieldInfo(TIFF *tif, uint32 tag, TIFFDataType dt)
---
> const TIFFFieldInfo*
> _TIFFFindOrRegisterFieldInfo( TIFF *tif, uint32 tag, TIFFDataType dt )
723c563
< 	const TIFFField *fld;
---
>     const TIFFFieldInfo *fld;
725,730c565,571
< 	fld = _TIFFFindField(tif, tag, dt);
< 	if (fld == NULL) {
< 		fld = _TIFFCreateAnonField(tif, tag, dt);
< 		if (!_TIFFMergeField(tif, fld, 1))
< 			return NULL;
< 	}
---
>     fld = _TIFFFindFieldInfo( tif, tag, dt );
>     if( fld == NULL )
>     {
>         fld = _TIFFCreateAnonFieldInfo( tif, tag, dt );
>         if (!_TIFFMergeFieldInfo(tif, fld, 1))
> 		return NULL;
>     }
732c573
< 	return fld;
---
>     return fld;
735,736c576,577
< TIFFField*
< _TIFFCreateAnonField(TIFF *tif, uint32 tag, TIFFDataType field_type)
---
> TIFFFieldInfo*
> _TIFFCreateAnonFieldInfo(TIFF *tif, uint32 tag, TIFFDataType field_type)
738c579
< 	TIFFField *fld;
---
> 	TIFFFieldInfo *fld;
741c582
< 	fld = (TIFFField *) _TIFFmalloc(sizeof (TIFFField));
---
> 	fld = (TIFFFieldInfo *) _TIFFmalloc(sizeof (TIFFFieldInfo));
744c585
< 	_TIFFmemset(fld, 0, sizeof(TIFFField));
---
> 	_TIFFmemset( fld, 0, sizeof(TIFFFieldInfo) );
