Use the actual size of memory allocations to update the memory status
counters. Fix the roundup() function of mem3 to be much closer to the
actual allocation size. Ticket #3226. (CVS 5440)
FossilOrigin-Name: 5c22132eb171058f30ec5b7562b8164611236748
diff --git a/src/malloc.c b/src/malloc.c
index 317061c..86ba2be 100644
--- a/src/malloc.c
+++ b/src/malloc.c
@@ -12,7 +12,7 @@
**
** Memory allocation functions used throughout sqlite.
**
-** $Id: malloc.c,v 1.28 2008/07/14 12:38:21 drh Exp $
+** $Id: malloc.c,v 1.29 2008/07/18 18:56:17 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
@@ -224,7 +224,10 @@
sqlite3MallocAlarm(nFull);
p = sqlite3Config.m.xMalloc(nFull);
}
- if( p ) sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nFull);
+ if( p ){
+ nFull = sqlite3MallocSize(p);
+ sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nFull);
+ }
*pp = p;
return nFull;
}
@@ -504,6 +507,7 @@
pNew = sqlite3Config.m.xRealloc(pOld, nNew);
}
if( pNew ){
+ nNew = sqlite3MallocSize(pNew);
sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nNew-nOld);
}
}