Additional changes to reduce stack usage. The SQLITE_SMALL_STACK compile-time
option is now available. (CVS 6708) FossilOrigin-Name: baea79fd0cfeb860973846c3f2776776c87f0ae3
This commit is contained in:
+10
-5
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user