aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/util.c b/src/util.c
index b4979ba44..bcf55e0a0 100644
--- a/src/util.c
+++ b/src/util.c
@@ -14,7 +14,7 @@
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
-** $Id: util.c,v 1.233 2008/07/06 00:21:35 drh Exp $
+** $Id: util.c,v 1.234 2008/07/08 14:52:10 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
@@ -42,6 +42,20 @@ int sqlite3IsNaN(double x){
}
/*
+** Return the length of a string, except do not allow the string length
+** to exceed the SQLITE_LIMIT_LENGTH setting.
+*/
+int sqlite3Strlen(sqlite3 *db, const char *z){
+ const char *z2 = z;
+ while( *z2 ){ z2++; }
+ if( z2 > &z[db->aLimit[SQLITE_LIMIT_LENGTH]] ){
+ return db->aLimit[SQLITE_LIMIT_LENGTH];
+ }else{
+ return (int)(z2 - z);
+ }
+}
+
+/*
** Set the most recent error code and error string for the sqlite
** handle "db". The error code is set to "err_code".
**