mirror of
https://github.com/glebarez/go-sqlite.git
synced 2025-10-05 15:56:52 +08:00
Add Initial content.
This commit is contained in:
62
main.c
Normal file
62
main.c
Normal file
@@ -0,0 +1,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;
|
||||
}
|
Reference in New Issue
Block a user