aboutsummaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
authordrh <>2022-04-15 15:47:14 +0000
committerdrh <>2022-04-15 15:47:14 +0000
commita99e325468d0c46919cf8a88f7c0b5bb8a4987a8 (patch)
tree3d929a2ac23c4e6acd1a1aadd57ed06c39939f28 /src/expr.c
parent358424aeff71bc8b38053b822091f4c6532ec5b1 (diff)
downloadsqlite-a99e325468d0c46919cf8a88f7c0b5bb8a4987a8.tar.gz
sqlite-a99e325468d0c46919cf8a88f7c0b5bb8a4987a8.zip
Enhance the IdList object to exist in a single memory allocation (rather than
a separate allocate for the base object and the array of IDs). Also permit an IdList object to store an Expr pointer together with each name. FossilOrigin-Name: 40f3c95871e6f40f287ef2756abafb8fc56dffdd0af69436e5c7d8e95022d94e
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/expr.c b/src/expr.c
index e6d7f9e69..4e036c934 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -1698,22 +1698,16 @@ IdList *sqlite3IdListDup(sqlite3 *db, const IdList *p){
int i;
assert( db!=0 );
if( p==0 ) return 0;
- pNew = sqlite3DbMallocRawNN(db, sizeof(*pNew) );
+ assert( p->eU4!=EU4_EXPR );
+ pNew = sqlite3DbMallocRawNN(db, sizeof(*pNew)+(p->nId-1)*sizeof(p->a[0]) );
if( pNew==0 ) return 0;
pNew->nId = p->nId;
- pNew->a = sqlite3DbMallocRawNN(db, p->nId*sizeof(p->a[0]) );
- if( pNew->a==0 ){
- sqlite3DbFreeNN(db, pNew);
- return 0;
- }
- /* Note that because the size of the allocation for p->a[] is not
- ** necessarily a power of two, sqlite3IdListAppend() may not be called
- ** on the duplicate created by this function. */
+ pNew->eU4 = p->eU4;
for(i=0; i<p->nId; i++){
struct IdList_item *pNewItem = &pNew->a[i];
- struct IdList_item *pOldItem = &p->a[i];
+ const struct IdList_item *pOldItem = &p->a[i];
pNewItem->zName = sqlite3DbStrDup(db, pOldItem->zName);
- pNewItem->idx = pOldItem->idx;
+ pNewItem->u4 = pOldItem->u4;
}
return pNew;
}