aboutsummaryrefslogtreecommitdiff
path: root/src/func.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2009-06-03 01:24:54 +0000
committerdrh <drh@noemail.net>2009-06-03 01:24:54 +0000
commit50d654da3b6768d4ec65e54405fc9763ff3a58d4 (patch)
tree430016c42e2c66a6ae293c5dd0bff48a66da8cf0 /src/func.c
parente98c9049a0a56ea8c3a704a986298f1dc5a9af2f (diff)
downloadsqlite-50d654da3b6768d4ec65e54405fc9763ff3a58d4.tar.gz
sqlite-50d654da3b6768d4ec65e54405fc9763ff3a58d4.zip
Additional changes to reduce stack usage. The SQLITE_SMALL_STACK compile-time
option is now available. (CVS 6708) FossilOrigin-Name: baea79fd0cfeb860973846c3f2776776c87f0ae3
Diffstat (limited to 'src/func.c')
-rw-r--r--src/func.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/func.c b/src/func.c
index 893406ceb..673b77e30 100644
--- a/src/func.c
+++ b/src/func.c
@@ -16,7 +16,7 @@
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** All other code has file scope.
**
-** $Id: func.c,v 1.236 2009/05/28 01:00:55 drh Exp $
+** $Id: func.c,v 1.237 2009/06/03 01:24:54 drh Exp $
*/
#include "sqliteInt.h"
#include <stdlib.h>
@@ -247,7 +247,7 @@ static void substrFunc(
static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
int n = 0;
double r;
- char zBuf[500]; /* larger than the %f representation of the largest double */
+ char *zBuf;
assert( argc==1 || argc==2 );
if( argc==2 ){
if( SQLITE_NULL==sqlite3_value_type(argv[1]) ) return;
@@ -257,9 +257,14 @@ static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
}
if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
r = sqlite3_value_double(argv[0]);
- sqlite3_snprintf(sizeof(zBuf),zBuf,"%.*f",n,r);
- sqlite3AtoF(zBuf, &r);
- sqlite3_result_double(context, r);
+ zBuf = sqlite3_mprintf("%.*f",n,r);
+ if( zBuf==0 ){
+ sqlite3_result_error_nomem(context);
+ }else{
+ sqlite3AtoF(zBuf, &r);
+ sqlite3_free(zBuf);
+ sqlite3_result_double(context, r);
+ }
}
#endif