/* Setup a directory entry for an NxM table of shorts, where M is known to be 2**bitspersample, and write the associated indirect data.  */
static int TIFFWriteShortTable(TIFF *, ttag_t, TIFFDirEntry *, uint32, uint16 **)
/* Setup a directory entry for an NxM table of shorts, where M is known to be 2**bitspersample, and write the associated indirect data.  */
static int TIFFWriteShortTable(TIFF *, ttag_t, TIFFDirEntry *, uint32, uint16 **)
{
	uint32 i, off;
	dir->tdir_tag = tag;
	dir->tdir_type = (short) TIFF_SHORT;
	dir->tdir_count = (uint32) (1L<<tif->tif_dir.td_bitspersample);
	off = tif->tif_dataoff;
	for (i = 0; i < n; i++)
		if (!TIFFWriteData(tif, dir, (char *)table[i]))
			return (0);
	dir->tdir_count *= n;
	dir->tdir_offset = off;
	return (1);
}