static int
LZWSetupDecode(TIFF* tif)
{
	static const char module[] = "LZWSetupDecode";
	LZWCodecState* sp = DecoderState(tif);
	int code;
	if( sp == NULL )
	{
		tif->tif_data = (uint8*) _TIFFmalloc(sizeof(LZWCodecState));
		if (tif->tif_data == NULL)
		{
			TIFFErrorExt(tif->tif_clientdata, module, "No space for LZW state block");
			return (0);
		}
		DecoderState(tif)->dec_codetab = NULL;
		DecoderState(tif)->dec_decode = NULL;
		(void) TIFFPredictorInit(tif);
		sp = DecoderState(tif);
	}
	assert(sp != NULL);
	if (sp->dec_codetab == NULL) {
		sp->dec_codetab = (code_t*)_TIFFmalloc(CSIZE*sizeof (code_t));
		if (sp->dec_codetab == NULL) {
			TIFFErrorExt(tif->tif_clientdata, module,
				     "No space for LZW code table");
			return (0);
		}
		code = 255;
		do {
			sp->dec_codetab[code].value = (unsigned char)code;
			sp->dec_codetab[code].firstchar = (unsigned char)code;
			sp->dec_codetab[code].length = 1;
			sp->dec_codetab[code].next = NULL;
		} while (code--);
                 _TIFFmemset(&sp->dec_codetab[CODE_CLEAR], 0,
			     (CODE_FIRST - CODE_CLEAR) * sizeof (code_t));
	}
	return (1);
}
['static int\nLZWSetupDecode(TIFF* tif)\n{\n\tstatic const char module[] = "LZWSetupDecode";\n\tLZWCodecState* sp = DecoderState(tif);\n\tint code;\n\tif( sp == NULL )\n\t{\n\t\ttif->tif_data = (uint8*) _TIFFmalloc(sizeof(LZWCodecState));\n\t\tif (tif->tif_data == NULL)\n\t\t{\n\t\t\tTIFFErrorExt(tif->tif_clientdata, module, "No space for LZW state block");\n\t\t\treturn (0);\n\t\t}\n\t\tDecoderState(tif)->dec_codetab = NULL;\n\t\tDecoderState(tif)->dec_decode = NULL;\n\t\t(void) TIFFPredictorInit(tif);\n\t\tsp = DecoderState(tif);\n\t}\n\tassert(sp != NULL);\n\tif (sp->dec_codetab == NULL) {\n\t\tsp->dec_codetab = (code_t*)_TIFFmalloc(CSIZE*sizeof (code_t));\n\t\tif (sp->dec_codetab == NULL) {\n\t\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t\t     "No space for LZW code table");\n\t\t\treturn (0);\n\t\t}\n\t\tcode = 255;\n\t\tdo {\n\t\t\tsp->dec_codetab[code].value = (unsigned char)code;\n\t\t\tsp->dec_codetab[code].firstchar = (unsigned char)code;\n\t\t\tsp->dec_codetab[code].length = 1;\n\t\t\tsp->dec_codetab[code].next = NULL;\n\t\t} while (code--);\n                 _TIFFmemset(&sp->dec_codetab[CODE_CLEAR], 0,\n\t\t\t     (CODE_FIRST - CODE_CLEAR) * sizeof (code_t));\n\t}\n\treturn (1);\n}', 'void*\n_TIFFmalloc(tmsize_t s)\n{\n        if (s == 0)\n                return ((void *) NULL);\n\treturn (malloc((size_t) s));\n}', 'int\nTIFFPredictorInit(TIFF* tif)\n{\n\tTIFFPredictorState* sp = PredictorState(tif);\n\tassert(sp != 0);\n\tif (!_TIFFMergeFields(tif, predictFields,\n\t\t\t      TIFFArrayCount(predictFields))) {\n\t\tTIFFErrorExt(tif->tif_clientdata, "TIFFPredictorInit",\n\t\t    "Merging Predictor codec-specific tags failed");\n\t\treturn 0;\n\t}\n\tsp->vgetparent = tif->tif_tagmethods.vgetfield;\n\ttif->tif_tagmethods.vgetfield =\n            PredictorVGetField;\n\tsp->vsetparent = tif->tif_tagmethods.vsetfield;\n\ttif->tif_tagmethods.vsetfield =\n\t    PredictorVSetField;\n\tsp->printdir = tif->tif_tagmethods.printdir;\n\ttif->tif_tagmethods.printdir =\n            PredictorPrintDir;\n\tsp->setupdecode = tif->tif_setupdecode;\n\ttif->tif_setupdecode = PredictorSetupDecode;\n\tsp->setupencode = tif->tif_setupencode;\n\ttif->tif_setupencode = PredictorSetupEncode;\n\tsp->predictor = 1;\n\tsp->encodepfunc = NULL;\n\tsp->decodepfunc = NULL;\n\treturn 1;\n}', 'void\nTIFFErrorExt(thandle_t fd, const char* module, const char* fmt, ...)\n{\n\tva_list ap;\n\tif (_TIFFerrorHandler) {\n\t\tva_start(ap, fmt);\n\t\t(*_TIFFerrorHandler)(module, fmt, ap);\n\t\tva_end(ap);\n\t}\n\tif (_TIFFerrorHandlerExt) {\n\t\tva_start(ap, fmt);\n\t\t(*_TIFFerrorHandlerExt)(fd, module, fmt, ap);\n\t\tva_end(ap);\n\t}\n}']