aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authordanielk1977 <danielk1977@noemail.net>2004-06-18 04:24:54 +0000
committerdanielk1977 <danielk1977@noemail.net>2004-06-18 04:24:54 +0000
commitbfd6cce56bbb02a96fd7599ff89e1e807fa2df29 (patch)
treee0d7c19ec2260b540dc806932b07a75dec67f2d9 /src/util.c
parenta2854229224e9e13eab1a9e9031057e6a259c38c (diff)
downloadsqlite-bfd6cce56bbb02a96fd7599ff89e1e807fa2df29.tar.gz
sqlite-bfd6cce56bbb02a96fd7599ff89e1e807fa2df29.zip
Optimisation for unicode encoding conversion routines. (CVS 1614)
FossilOrigin-Name: 39a415eaa65964742e40b7ea4d471fa04007c6c9
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/util.c b/src/util.c
index 002bc2d35..29cd56112 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.102 2004/06/16 07:45:29 danielk1977 Exp $
+** $Id: util.c,v 1.103 2004/06/18 04:24:55 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
@@ -256,6 +256,13 @@ char *sqlite3StrNDup_(const char *z, int n, char *zFile, int line){
}
return zNew;
}
+
+/*
+** A version of sqliteFree that is always a function, not a macro.
+*/
+void sqlite3FreeX(void *p){
+ sqliteFree(p);
+}
#endif /* SQLITE_DEBUG */
/*
@@ -446,23 +453,18 @@ void sqlite3SetNString(char **pz, ...){
** to NULL.
*/
void sqlite3Error(sqlite *db, int err_code, const char *zFormat, ...){
- /* Free any existing error message. */
- if( db->zErrMsg ){
- sqliteFree(db->zErrMsg);
- db->zErrMsg = 0;
- }
- if( db->zErrMsg16 ){
- sqliteFree(db->zErrMsg16);
- db->zErrMsg16 = 0;
- }
-
- /* Set the new error code and error message. */
- db->errCode = err_code;
- if( zFormat ){
- va_list ap;
- va_start(ap, zFormat);
- db->zErrMsg = sqlite3VMPrintf(zFormat, ap);
- va_end(ap);
+ if( db && (db->pErr || (db->pErr = sqlite3ValueNew())) ){
+ db->errCode = err_code;
+ if( zFormat ){
+ char *z;
+ va_list ap;
+ va_start(ap, zFormat);
+ z = sqlite3VMPrintf(zFormat, ap);
+ va_end(ap);
+ sqlite3ValueSetStr(db->pErr, -1, z, SQLITE_UTF8, sqlite3FreeX);
+ }else{
+ sqlite3ValueSetStr(db->pErr, 0, 0, SQLITE_UTF8, SQLITE_STATIC);
+ }
}
}