Ejemplo n.º 1
0
        /*
        **    sqlite3_intarray_bind  INTARRAY  ?VALUE ...?
        **
        ** Invoke the sqlite3_intarray_bind interface on the given array of integers.
        */
        static int test_intarray_bind(
            ClientData clientData, /* Not used */
            Tcl_Interp interp,     /* The TCL interpreter that invoked this command */
            int objc,              /* Number of arguments */
            Tcl_Obj[] objv         /* Command arguments */
            )
        {
            sqlite3_intarray pArray;
            int rc = SQLITE_OK;
            int i, n;

            sqlite3_int64[] a;

            if (objc < 2)
            {
                TCL.Tcl_WrongNumArgs(interp, 1, objv, "INTARRAY");
                return(TCL.TCL_ERROR);
            }
            pArray = (sqlite3_intarray)sqlite3TestTextToPtr(interp, TCL.Tcl_GetString(objv[1]));
            n      = objc - 2;
#if !SQLITE_OMIT_VIRTUALTABLE
            a = new sqlite3_int64[n];//sqlite3_malloc( sizeof(a[0])*n );
            //if( a==0 ){
            //  Tcl_AppendResult(interp, "SQLITE_NOMEM", (char*)0);
            //  return TCL_ERROR;
            //}
            for (i = 0; i < n; i++)
            {
                //a[i] = 0;
                TCL.Tcl_GetWideIntFromObj(null, objv[i + 2], out a[i]);
            }
            rc = sqlite3_intarray_bind(pArray, n, a, sqlite3_free);
            if (rc != SQLITE_OK)
            {
                TCL.Tcl_AppendResult(interp, sqlite3TestErrorName(rc), null);
                return(TCL.TCL_ERROR);
            }
#endif
            return(TCL.TCL_OK);
        }