diff options
author | dan <dan@noemail.net> | 2010-08-27 17:48:52 +0000 |
---|---|---|
committer | dan <dan@noemail.net> | 2010-08-27 17:48:52 +0000 |
commit | d2199f0f8d8f16b1b9ce39eba8d5763d246f6502 (patch) | |
tree | 4da782d74b5fbf9e0f13e696bbb5d450e9ba2685 /src/sqliteInt.h | |
parent | badc980afa4ae2fb94cce8182bb31346ed91f7c7 (diff) | |
download | sqlite-d2199f0f8d8f16b1b9ce39eba8d5763d246f6502.tar.gz sqlite-d2199f0f8d8f16b1b9ce39eba8d5763d246f6502.zip |
Add the sqlite3_create_function_v2() API, a version of create_function that allows a destructor to be specified.
FossilOrigin-Name: 9a724dfbe822c77e76721abe3443c9cb018bb2e2
Diffstat (limited to 'src/sqliteInt.h')
-rw-r--r-- | src/sqliteInt.h | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 6c41315f8..90d900d69 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -600,6 +600,7 @@ typedef struct Expr Expr; typedef struct ExprList ExprList; typedef struct ExprSpan ExprSpan; typedef struct FKey FKey; +typedef struct FuncDestructor FuncDestructor; typedef struct FuncDef FuncDef; typedef struct FuncDefHash FuncDefHash; typedef struct IdList IdList; @@ -956,6 +957,27 @@ struct FuncDef { void (*xFinalize)(sqlite3_context*); /* Aggregate finalizer */ char *zName; /* SQL name of the function. */ FuncDef *pHash; /* Next with a different name but the same hash */ + FuncDestructor *pDestructor; /* Reference counted destructor function */ +}; + +/* +** This structure encapsulates a user-function destructor callback (as +** configured using create_function_v2()) and a reference counter. When +** create_function_v2() is called to create a function with a destructor, +** a single object of this type is allocated. FuncDestructor.nRef is set to +** the number of FuncDef objects created (either 1 or 3, depending on whether +** or not the specified encoding is SQLITE_ANY). The FuncDef.pDestructor +** member of each of the new FuncDef objects is set to point to the allocated +** FuncDestructor. +** +** Thereafter, when one of the FuncDef objects is deleted, the reference +** count on this object is decremented. When it reaches 0, the destructor +** is invoked and the FuncDestructor structure freed. +*/ +struct FuncDestructor { + int nRef; + void (*xDestroy)(void *); + void *pUserData; }; /* @@ -2921,7 +2943,9 @@ int sqlite3SchemaToIndex(sqlite3 *db, Schema *); KeyInfo *sqlite3IndexKeyinfo(Parse *, Index *); int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *, void (*)(sqlite3_context*,int,sqlite3_value **), - void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*)); + void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*), + FuncDestructor *pDestructor +); int sqlite3ApiExit(sqlite3 *db, int); int sqlite3OpenTempDatabase(Parse *); |