/ Check-in [305cc4e6]
Login

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

Overview
Comment:Add assert() statements to demonstrate that memory allocations are always aligned to an 8-byte boundary (unless SQLITE_4_BYTE_ALIGNED_MALLOC is defined).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 305cc4e6c1164b1ede0c3177e3c0f9b8644df0f6
User & Date: drh 2010-09-11 15:54:53
Context
2010-09-11
16:15
Additional evidence marks on the malloc() implementation. Update the documentation to explain that mallocs are not necessarily 8-byte aligned if the SQLITE_4_BYTE_ALIGNED_MALLOC compile-time option is used. check-in: 42b4bf9e user: drh tags: trunk
15:54
Add assert() statements to demonstrate that memory allocations are always aligned to an 8-byte boundary (unless SQLITE_4_BYTE_ALIGNED_MALLOC is defined). check-in: 305cc4e6 user: drh tags: trunk
05:15
When building from the amalgamation with ENABLE_RTREE defined, do not try to include sqlite3rtree.h. check-in: 5b63e981 user: dan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/malloc.c.

303
304
305
306
307
308
309

310
311
312
313
314
315
316
...
540
541
542
543
544
545
546

547
548
549
550
551
552
553
  }else if( sqlite3GlobalConfig.bMemstat ){
    sqlite3_mutex_enter(mem0.mutex);
    mallocWithAlarm(n, &p);
    sqlite3_mutex_leave(mem0.mutex);
  }else{
    p = sqlite3GlobalConfig.m.xMalloc(n);
  }

  return p;
}

/*
** This version of the memory allocation is for use by the application.
** First make sure the memory subsystem is initialized, then do the
** allocation.
................................................................................
      nNew = sqlite3MallocSize(pNew);
      sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nNew-nOld);
    }
    sqlite3_mutex_leave(mem0.mutex);
  }else{
    pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);
  }

  return pNew;
}

/*
** The public interface to sqlite3Realloc.  Make sure that the memory
** subsystem is initialized prior to invoking sqliteRealloc.
*/







>







 







>







303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
...
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
  }else if( sqlite3GlobalConfig.bMemstat ){
    sqlite3_mutex_enter(mem0.mutex);
    mallocWithAlarm(n, &p);
    sqlite3_mutex_leave(mem0.mutex);
  }else{
    p = sqlite3GlobalConfig.m.xMalloc(n);
  }
  assert( EIGHT_BYTE_ALIGNMENT(p) );  /* IMP: R-36023-12588 */
  return p;
}

/*
** This version of the memory allocation is for use by the application.
** First make sure the memory subsystem is initialized, then do the
** allocation.
................................................................................
      nNew = sqlite3MallocSize(pNew);
      sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nNew-nOld);
    }
    sqlite3_mutex_leave(mem0.mutex);
  }else{
    pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);
  }
  assert( EIGHT_BYTE_ALIGNMENT(pNew) ); /* IMP: R-36023-12588 */
  return pNew;
}

/*
** The public interface to sqlite3Realloc.  Make sure that the memory
** subsystem is initialized prior to invoking sqliteRealloc.
*/