//
// TIFFWriteBufferSetup from 0x6f49f8 to 0x6f4b9c (420 bytes)
//
// 6 xrefs:
// > TIFFWriteScanline @ 0x6f3394
// > TIFFWriteEncodedStrip @ 0x6f3958
// > TIFFWriteEncodedStrip @ 0x6f3acc
// > TIFFWriteEncodedTile @ 0x6f4008
// > TIFFWriteEncodedTile @ 0x6f4100
// > ??> @ 0x5894c
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
int __fastcall TIFFWriteBufferSetup(_DWORD *a1, int a2, int a3)
{
int v3; // r3
if ( a1[147] )
{
if ( (a1[3] & 0x200) != 0 )
{
TIFFfree(a1[147]);
a1[3] &= ~0x200u;
}
a1[147] = 0;
}
if ( a3 == -1 )
{
if ( (a1[3] & 0x400) != 0 )
v3 = a1[124];
else
v3 = TIFFStripSize((int)a1);
a3 = v3;
if ( v3 <= 0x1FFF )
a3 = 0x2000;
a2 = 0;
}
if ( a2 )
{
a1[3] &= ~0x200u;
goto LABEL_17;
}
a2 = TIFFmalloc(a3);
if ( a2 )
{
a1[3] |= 0x200u;
LABEL_17:
a1[147] = a2;
a1[148] = a3;
a1[152] = 0;
a1[151] = a1[147];
a1[3] |= 0x10u;
return 1;
}
TIFFErrorExt(a1[157], (int)"TIFFWriteBufferSetup", "No space for output buffer");
return 0;
}