void
TIFFSwabArrayOfShort(register uint16* wp, tmsize_t n)
{
	register unsigned char* cp;
	register unsigned char t;
	assert(sizeof(uint16)==2);
	while (n-- > 0) {
		cp = (unsigned char*) wp;
		t = cp[1]; cp[1] = cp[0]; cp[0] = t;
		wp++;
	}
}
['static int\nTIFFWriteDirectoryTagColormap(TIFF* tif, uint32* ndir, TIFFDirEntry* dir)\n{\n\tstatic const char module[] = "TIFFWriteDirectoryTagColormap";\n\tuint32 m;\n\tuint16* n;\n\tint o;\n\tif (dir==NULL)\n\t{\n\t\t(*ndir)++;\n\t\treturn(1);\n\t}\n\tm=(1<<tif->tif_dir.td_bitspersample);\n\tn=_TIFFmalloc(3*m*sizeof(uint16));\n\tif (n==NULL)\n\t{\n\t\tTIFFErrorExt(tif->tif_clientdata,module,"Out of memory");\n\t\treturn(0);\n\t}\n\t_TIFFmemcpy(&n[0],tif->tif_dir.td_colormap[0],m*sizeof(uint16));\n\t_TIFFmemcpy(&n[m],tif->tif_dir.td_colormap[1],m*sizeof(uint16));\n\t_TIFFmemcpy(&n[2*m],tif->tif_dir.td_colormap[2],m*sizeof(uint16));\n\to=TIFFWriteDirectoryTagCheckedShortArray(tif,ndir,dir,TIFFTAG_COLORMAP,3*m,n);\n\t_TIFFfree(n);\n\treturn(o);\n}', 'void*\n_TIFFmalloc(tmsize_t s)\n{\n\treturn (malloc((size_t) s));\n}', 'static int\nTIFFWriteDirectoryTagCheckedShortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint16* value)\n{\n\tassert(count<0x80000000);\n\tassert(sizeof(uint16)==2);\n\tif (tif->tif_flags&TIFF_SWAB)\n\t\tTIFFSwabArrayOfShort(value,count);\n\treturn(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SHORT,count,count*2,value));\n}', 'void\nTIFFSwabArrayOfShort(register uint16* wp, tmsize_t n)\n{\n\tregister unsigned char* cp;\n\tregister unsigned char t;\n\tassert(sizeof(uint16)==2);\n\twhile (n-- > 0) {\n\t\tcp = (unsigned char*) wp;\n\t\tt = cp[1]; cp[1] = cp[0]; cp[0] = t;\n\t\twp++;\n\t}\n}']