aboutsummaryrefslogtreecommitdiff
path: root/main.c
blob: 50d19fd3a285e81e93b2cacc647a1ec70e8c80ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// +build ignore

// SQLite Is Public Domain
// 
// All of the code and documentation in SQLite has been dedicated to the public
// domain by the authors. All code authors, and representatives of the
// companies they work for, have signed affidavits dedicating their
// contributions to the public domain and originals of those signed affidavits
// are stored in a firesafe at the main offices of Hwaci. Anyone is free to
// copy, modify, publish, use, compile, sell, or distribute the original SQLite
// code, either in source code form or as a compiled binary, for any purpose,
// commercial or non-commercial, and by any means.
// 
// The previous paragraph applies to the deliverable code and documentation in
// SQLite - those parts of the SQLite library that you actually bundle and ship
// with a larger application. Some scripts used as part of the build process
// (for example the "configure" scripts generated by autoconf) might fall under
// other open-source licenses. Nothing from these build scripts ever reaches
// the final deliverable SQLite library, however, and so the licenses
// associated with those scripts should not be a factor in assessing your
// rights to copy and use the SQLite library.
// 
// All of the deliverable code in SQLite has been written from scratch. No code
// has been taken from other projects or from the open internet. Every line of
// code can be traced back to its original author, and all of those authors
// have public domain dedications on file. So the SQLite code base is clean and
// is uncontaminated with licensed code from other projects.

#define minAlloc (2<<5)

#include <sqlite3.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
	if (argc != 2) {
		return 1;
	}

	int heapSize = 0;
	char *p = argv[1];
	for (; *p; p++) {
		heapSize = 10 * heapSize + *p - '0';
	}

	void *heap = malloc(heapSize);
	if (heap == 0) {
		return 1;
	}

	int rc = sqlite3_config(SQLITE_CONFIG_HEAP, heap, heapSize, minAlloc);
	if (rc) {
		return 2;
	}

	rc = sqlite3_threadsafe();
	if (!rc) {
		return 3;
	}

	return 0;
}