1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Cleanup the processing of MEM_Agg elements. (CVS 2660)

FossilOrigin-Name: 7ecf3654aa9a275a4cf0c3ec5f63a8c1e0a11fc9
This commit is contained in:
drh
2005-09-06 20:36:48 +00:00
parent 1ec43c9a5a
commit abfcea25ea
8 changed files with 81 additions and 82 deletions

View File

@@ -258,15 +258,18 @@ void *sqlite3_user_data(sqlite3_context *p){
*/
void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){
assert( p && p->pFunc && p->pFunc->xStep );
if( p->pAgg==0 ){
Mem *pMem = p->pMem;
if( (pMem->flags & MEM_Agg)==0 && nByte>0 ){
pMem->flags = MEM_Agg;
*(FuncDef**)&pMem->i = p->pFunc;
if( nByte<=NBFS ){
p->pAgg = (void*)p->s.z;
memset(p->pAgg, 0, nByte);
pMem->z = pMem->zShort;
memset(pMem->z, 0, nByte);
}else{
p->pAgg = sqliteMalloc( nByte );
pMem->z = sqliteMalloc( nByte );
}
}
return p->pAgg;
return (void*)pMem->z;
}
/*
@@ -325,7 +328,7 @@ void sqlite3_set_auxdata(
*/
int sqlite3_aggregate_count(sqlite3_context *p){
assert( p && p->pFunc && p->pFunc->xStep );
return p->cnt;
return p->pMem->n;
}
/*