Ejemplo n.º 1
0
/*----------------------------------------------------------------------------------------------
	Main procedure for this console application: creating a FieldWorks database from XML.
----------------------------------------------------------------------------------------------*/
int main(int argc, char ** argv)
{
	// Temporary (?) hack to sidestep bug in Microsoft's C runtime library.
	_set_sbh_threshold(0);

	// Check for memory leaks
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);

	char * pszOutputDB = NULL;
	char * pszOutputDir = NULL;
	char * pszServer = NULL;
	char * pszInitFile = NULL;
	bool fForceCreate = false;
	int ch;
	bool fError = false;
	char szLocal[MAX_COMPUTERNAME_LENGTH + 1];

	while ((ch = getopt(argc, argv, "d:fi:s:o:")) != EOF)
	{
		switch (ch)
		{
		case 'd':
			pszOutputDB = optarg;
			break;
		case 'o':
			pszOutputDir = optarg;
			break;
		case 'f':
			fForceCreate = true;
			break;
		case 'i':
			pszInitFile = optarg;
			break;
		case 's':
			pszServer = optarg;
			break;
		default:
			fError = true;
			break;
		}
	}
	if (!pszOutputDB || fError)
	{
		printf("\
Usage: CreateDb -d outputdb [-f] [-i init.sql] [-s server]\n\
   -d outputdb  = the output database (no default)\n\
   -o outputdir = the dir where the database files are created(default: default data dir)\n\
   -f           = force recreating an existing database\n\
   -i init.sql  = the initialization SQL script (default: no initialization)\n\
   -s server    = the server where the database is located (default: local system)\n\
");
		exit(1);
	}
Ejemplo n.º 2
0
void qsInit(void *module)
{
	if (!qsInitialized) {

#if defined(_WINDOWS) || defined(WIN32)
		system("del /q /f __db.??? >nul 2>nul");
		_setmaxstdio(2048);
		_set_sbh_threshold(0);
#endif
		qsInitialized = true;

	}
}
Ejemplo n.º 3
0
static void test_sbheap(void)
{
    void *mem;
    int threshold;

    if(sizeof(void*) == 8) {
        ok(!_set_sbh_threshold(0), "_set_sbh_threshold succeeded\n");
        ok(!_set_sbh_threshold(1000), "_set_sbh_threshold succeeded\n");
        return;
    }

    mem = malloc(1);
    ok(mem != NULL, "malloc failed\n");

    ok(_set_sbh_threshold(1), "_set_sbh_threshold failed\n");
    threshold = _get_sbh_threshold();
    ok(threshold == 16, "threshold = %d\n", threshold);

    ok(_set_sbh_threshold(8), "_set_sbh_threshold failed\n");
    threshold = _get_sbh_threshold();
    ok(threshold == 16, "threshold = %d\n", threshold);

    ok(_set_sbh_threshold(1000), "_set_sbh_threshold failed\n");
    threshold = _get_sbh_threshold();
    ok(threshold == 1008, "threshold = %d\n", threshold);

    free(mem);

    mem = malloc(1);
    ok(mem != NULL, "malloc failed\n");
    ok(!((UINT_PTR)mem & 0xf), "incorrect alignment (%p)\n", mem);

    mem = realloc(mem, 10);
    ok(mem != NULL, "realloc failed\n");
    ok(!((UINT_PTR)mem & 0xf), "incorrect alignment (%p)\n", mem);

    ok(_set_sbh_threshold(0), "_set_sbh_threshold failed\n");
    threshold = _get_sbh_threshold();
    ok(threshold == 0, "threshold = %d\n", threshold);

    free(mem);
}