typedef struct RtreeNode RtreeNode;
typedef struct RtreeCell RtreeCell;
typedef struct RtreeConstraint RtreeConstraint;
+typedef struct RtreeMatchArg RtreeMatchArg;
+typedef struct RtreeGeomCallback RtreeGeomCallback;
typedef union RtreeCoord RtreeCoord;
-typedef struct RtreeGeomBlob RtreeGeomBlob;
/* The rtree may have between 1 and RTREE_MAX_DIMENSIONS dimensions. */
#define RTREE_MAX_DIMENSIONS 5
/*
-** Value for the first field of every RtreeGeomBlob object. The MATCH
+** Value for the first field of every RtreeMatchArg object. The MATCH
** operator tests that the first field of a blob operand matches this
** value to avoid operating on invalid blobs (which could cause a segfault).
*/
** the right-hand-side of an SQL MATCH operator used to constrain an
** r-tree query.
*/
-struct RtreeGeomBlob {
+struct RtreeMatchArg {
u32 magic; /* Always RTREE_GEOMETRY_MAGIC */
int (*xGeom)(sqlite3_rtree_geometry *, int, double *, int *);
void *pContext;
double aParam[1];
};
+/*
+** When a geometry callback is created (see sqlite3_rtree_geometry_callback),
+** a single instance of the following structure is allocated. It is used
+** as the context for the user-function created by by s_r_g_c(). The object
+** is eventually deleted by the destructor mechanism provided by
+** sqlite3_create_function_v2() (which is called by s_r_g_c() to create
+** the geometry callback function).
+*/
+struct RtreeGeomCallback {
+ int (*xGeom)(sqlite3_rtree_geometry *, int, double *, int *);
+ void *pContext;
+};
+
#ifndef MAX
# define MAX(x,y) ((x) < (y) ? (y) : (x))
#endif
** operator.
*/
static int deserializeGeometry(sqlite3_value *pValue, RtreeConstraint *pCons){
- RtreeGeomBlob *p;
+ RtreeMatchArg *p;
sqlite3_rtree_geometry *pGeom;
int nBlob;
/* Check that the blob is roughly the right size. */
nBlob = sqlite3_value_bytes(pValue);
- if( nBlob<sizeof(RtreeGeomBlob)
- || ((nBlob-sizeof(RtreeGeomBlob))%sizeof(double))!=0
+ if( nBlob<sizeof(RtreeMatchArg)
+ || ((nBlob-sizeof(RtreeMatchArg))%sizeof(double))!=0
){
return SQLITE_ERROR;
}
);
if( !pGeom ) return SQLITE_NOMEM;
memset(pGeom, 0, sizeof(sqlite3_rtree_geometry));
- p = (RtreeGeomBlob *)&pGeom[1];
+ p = (RtreeMatchArg *)&pGeom[1];
memcpy(p, sqlite3_value_blob(pValue), nBlob);
if( p->magic!=RTREE_GEOMETRY_MAGIC
- || nBlob!=(sizeof(RtreeGeomBlob) + (p->nParam-1)*sizeof(double))
+ || nBlob!=(sizeof(RtreeMatchArg) + (p->nParam-1)*sizeof(double))
){
sqlite3_free(pGeom);
return SQLITE_ERROR;
p->iCoord = idxStr[ii*2+1]-'a';
if( p->op==RTREE_MATCH ){
/* A MATCH operator. The right-hand-side must be a blob that
- ** can be cast into an RtreeGeomBlob object. One created using
+ ** can be cast into an RtreeMatchArg object. One created using
** an sqlite3_rtree_geometry_callback() SQL user function.
*/
rc = deserializeGeometry(argv[ii], p);
sqlite3_free(p);
}
-typedef struct GeomCallbackCtx GeomCallbackCtx;
-struct GeomCallbackCtx {
- int (*xGeom)(sqlite3_rtree_geometry *, int, double *, int *);
- void *pContext;
-};
-
/*
** Each call to sqlite3_rtree_geometry_callback() creates an ordinary SQLite
** scalar user function. This C function is the callback used for all such
** table MATCH operators.
*/
static void geomCallback(sqlite3_context *ctx, int nArg, sqlite3_value **aArg){
- GeomCallbackCtx *pGeomCtx = (GeomCallbackCtx *)sqlite3_user_data(ctx);
- RtreeGeomBlob *pBlob;
+ RtreeGeomCallback *pGeomCtx = (RtreeGeomCallback *)sqlite3_user_data(ctx);
+ RtreeMatchArg *pBlob;
int nBlob;
- nBlob = sizeof(RtreeGeomBlob) + (nArg-1)*sizeof(double);
- pBlob = (RtreeGeomBlob *)sqlite3_malloc(nBlob);
+ nBlob = sizeof(RtreeMatchArg) + (nArg-1)*sizeof(double);
+ pBlob = (RtreeMatchArg *)sqlite3_malloc(nBlob);
if( !pBlob ){
sqlite3_result_error_nomem(ctx);
}else{
int (*xGeom)(sqlite3_rtree_geometry *, int, double *, int *),
void *pContext
){
- GeomCallbackCtx *pGeomCtx; /* Context object for new user-function */
+ RtreeGeomCallback *pGeomCtx; /* Context object for new user-function */
/* Allocate and populate the context object. */
- pGeomCtx = (GeomCallbackCtx *)sqlite3_malloc(sizeof(GeomCallbackCtx));
+ pGeomCtx = (RtreeGeomCallback *)sqlite3_malloc(sizeof(RtreeGeomCallback));
if( !pGeomCtx ) return SQLITE_NOMEM;
pGeomCtx->xGeom = xGeom;
pGeomCtx->pContext = pContext;
------BEGIN PGP SIGNED MESSAGE-----
-Hash: SHA1
-
-C Fix\sa\sdocumentation\stypo\sreported\son\sthe\smailing\slist.
-D 2010-08-31T15:38:52
+C Changes\sto\scomments\sand\stype\snames\sin\srtree.c.
+D 2010-08-31T15:54:21
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in c599a15d268b1db2aeadea19df2adc3bf2eb6bee
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F ext/icu/icu.c 850e9a36567bbcce6bd85a4b68243cad8e3c2de2
F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37
F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
-F ext/rtree/rtree.c 556479bc9c32aa80316dc9edd18b8c47c9afaf8d
+F ext/rtree/rtree.c e26735d586497dbd037b3a6b2df25f9e6ea5b0ec
F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e
F ext/rtree/rtree1.test dbd4250ac0ad367a262eb9676f7e3080b0368206
F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 53b0c03fd33d2d8141fd386de5493fec64456042
-R 776e9f05b41cfbfcf208301fd66607f6
-U drh
-Z 57cd5b719d8ab02c054ea145e97a806a
------BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.6 (GNU/Linux)
-
-iD8DBQFMfSIOoxKgR168RlERAhLxAJ9gvWaCTQYE8HmwYXE4167pk0HbqQCfeun2
-BMlG7Oi5TtVFDPLSGQrymn4=
-=fndz
------END PGP SIGNATURE-----
+P c9fe0a2392ba4ae53d1dfcb986a67beeeb33519f
+R 301d7abc2fe21cc4b65e2daa2d7c00af
+U dan
+Z eacbd5c90af2b71f9a06ae40a306d809