/ Check-in [380f61df]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Change sqlite3StrAccumAppend() to use realloc instead of malloc.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 380f61df0754ceec6b3f6a758d04e951cce8c3d9
User & Date: dan 2011-01-21 18:25:30
Context
2011-01-22
13:32
Modify the trace callback mechanism so that SQL commands executed from within virtual table or user function callbacks are passed to the trace callback without parameter expansion and enclosed in SQL comments. check-in: a764915b user: dan tags: trunk
2011-01-21
18:25
Change sqlite3StrAccumAppend() to use realloc instead of malloc. check-in: 380f61df user: dan tags: trunk
15:52
Add options to test command [do_faultsim_test] to support testing VFS implementations. check-in: 503ad889 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/printf.c.

   759    759       if( !p->useMalloc ){
   760    760         p->tooBig = 1;
   761    761         N = p->nAlloc - p->nChar - 1;
   762    762         if( N<=0 ){
   763    763           return;
   764    764         }
   765    765       }else{
          766  +      char *zOld = (p->zText==p->zBase ? 0 : p->zText);
   766    767         i64 szNew = p->nChar;
   767    768         szNew += N + 1;
   768    769         if( szNew > p->mxAlloc ){
   769    770           sqlite3StrAccumReset(p);
   770    771           p->tooBig = 1;
   771    772           return;
   772    773         }else{
   773    774           p->nAlloc = (int)szNew;
   774    775         }
   775    776         if( p->useMalloc==1 ){
   776         -        zNew = sqlite3DbMallocRaw(p->db, p->nAlloc );
          777  +        zNew = sqlite3DbRealloc(p->db, zOld, p->nAlloc);
   777    778         }else{
   778         -        zNew = sqlite3_malloc(p->nAlloc);
          779  +        zNew = sqlite3_realloc(zOld, p->nAlloc);
   779    780         }
   780    781         if( zNew ){
   781         -        memcpy(zNew, p->zText, p->nChar);
   782         -        sqlite3StrAccumReset(p);
          782  +        if( zOld==0 ) memcpy(zNew, p->zText, p->nChar);
   783    783           p->zText = zNew;
   784    784         }else{
   785    785           p->mallocFailed = 1;
   786    786           sqlite3StrAccumReset(p);
   787    787           return;
   788    788         }
   789    789       }