/*****************************************************************************
 * FreeAdhocUDF - copyright (c) 2004 - 2008 adhoc dataservice GmbH
 * Christoph Theuring ct / Peter Mandrella pm / Georg Horn gh
 * <http://www.udf.adhoc-data.de> eMail <udf@adhoc-data.de>
 * based on FreeUDFLibC - copyright (c) 1999 Gregory Deatz
 *
 * File Name:	global.h
 * Description: This header contains the global prototype definitions
 *  
 * This file is part of FreeAdhocUDF.
 * FreeAdhocUDF is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * FreeAdhocUDF is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with FreeAdhocUDF.  If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/

#include "ibase.h"

#define LOC_STRING_SIZE 256
#define MAX_STRINGBUFFER_SIZE 32768

#if defined(__BORLANDC__) || defined(__MSVC__)
#define WINDOWS
#endif

// ct 2007-12-03 readded ib_util for ib_util_malloc because of memory leak under windows ???
// we don't understand this :-(
#include "ib_util.h"
//#define MALLOC ib_util_malloc
// pm 2006-09-24
// Workaround for Firebird bug (buffer overflow):
// Firebird writes data after end of returned UDF data.
// Allocation of the string buffer maximum of >= 32762 Bytes
// for all strings solves this problem.
// n is dummy referenced to avoid "unused variable" warning.
// FB_API_VER is only defined in ibase.h of FireBird
#ifdef FB_API_VER
#define MALLOC(n) (ib_util_malloc((n) - (n) + MAX_STRINGBUFFER_SIZE))
#else
#define MALLOC ib_util_malloc
#endif

