A cast can never fix an aliasing violation.

Andreas.

--- sqlite-3.6.16/src/vdbeaux.c.~1~     2009-06-26 20:17:20.000000000 +0200
+++ sqlite-3.6.16/src/vdbeaux.c 2009-11-27 19:19:02.000000000 +0100
@@ -1046,17 +1046,17 @@ void sqlite3VdbeIOTraceSql(Vdbe *p){
 ** request, then increment *pnByte by the amount of the request.
 */
 static void allocSpace(
-  char *pp,            /* IN/OUT: Set *pp to point to allocated buffer */
+  void **pp,            /* IN/OUT: Set *pp to point to allocated buffer */
   int nByte,           /* Number of bytes to allocate */
   u8 **ppFrom,         /* IN/OUT: Allocate from *ppFrom */
   u8 *pEnd,            /* Pointer to 1 byte past the end of *ppFrom buffer */
   int *pnByte          /* If allocation cannot be made, increment *pnByte */
 ){
   assert( EIGHT_BYTE_ALIGNMENT(*ppFrom) );
-  if( (*(void**)pp)==0 ){
+  if( (*pp)==0 ){
     nByte = ROUND8(nByte);
     if( (pEnd - *ppFrom)>=nByte ){
-      *(void**)pp = (void *)*ppFrom;
+      *pp = (void *)*ppFrom;
       *ppFrom += nByte;
     }else{
       *pnByte += nByte;
@@ -1131,15 +1131,26 @@ void sqlite3VdbeMakeReady(
     if( zEnd<zCsr ) zEnd = zCsr;
 
     do {
+      void *pp;
       memset(zCsr, 0, zEnd-zCsr);
       nByte = 0;
-      allocSpace((char*)&p->aMem, nMem*sizeof(Mem), &zCsr, zEnd, &nByte);
-      allocSpace((char*)&p->aVar, nVar*sizeof(Mem), &zCsr, zEnd, &nByte);
-      allocSpace((char*)&p->apArg, nArg*sizeof(Mem*), &zCsr, zEnd, &nByte);
-      allocSpace((char*)&p->azVar, nVar*sizeof(char*), &zCsr, zEnd, &nByte);
-      allocSpace((char*)&p->apCsr, 
+      pp = p->aMem;
+      allocSpace(&pp, nMem*sizeof(Mem), &zCsr, zEnd, &nByte);
+      p->aMem = pp;
+      pp = p->aVar;
+      allocSpace(&pp, nVar*sizeof(Mem), &zCsr, zEnd, &nByte);
+      p->aVar = pp;
+      pp = p->apArg;
+      allocSpace(&pp, nArg*sizeof(Mem*), &zCsr, zEnd, &nByte);
+      p->apArg = pp;
+      pp = p->azVar;
+      allocSpace(&pp, nVar*sizeof(char*), &zCsr, zEnd, &nByte);
+      p->azVar = pp;
+      pp = p->apCsr;
+      allocSpace(&pp, 
                  nCursor*sizeof(VdbeCursor*), &zCsr, zEnd, &nByte
       );
+      p->apCsr = pp;
       if( nByte ){
         p->pFree = sqlite3DbMallocRaw(db, nByte);
       }

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to