/ Check-in [657d74eb]
Login

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

Overview
Comment:Make sqlite3Malloc always return NULL when the number of bytes to allocate is 0. (CVS 2532)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:657d74ebc1d91c99e8ac6cd68fdac3864ebd8d71
User & Date: drh 2005-06-29 15:33:00
Context
2005-06-29
17:24
Check for zero-byte allocations in sqlite3MallocRaw. (CVS 2533) check-in: 78cb8a9a user: drh tags: trunk
15:33
Make sqlite3Malloc always return NULL when the number of bytes to allocate is 0. (CVS 2532) check-in: 657d74eb user: drh tags: trunk
2005-06-26
20:00
Update SQL syntax documentation to describe the new CAST expressions. (CVS 2531) check-in: d5392866 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/util.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** Utility functions used throughout sqlite.
    13     13   **
    14     14   ** This file contains functions for allocating memory, comparing
    15     15   ** strings, and stuff like that.
    16     16   **
    17         -** $Id: util.c,v 1.138 2005/06/25 18:42:15 drh Exp $
           17  +** $Id: util.c,v 1.139 2005/06/29 15:33:00 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include <stdarg.h>
    21     21   #include <ctype.h>
    22     22   
    23     23   #if SQLITE_MEMDEBUG>2 && defined(__GLIBC__)
    24     24   #include <execinfo.h>
................................................................................
   264    264   
   265    265   /*
   266    266   ** Allocate new memory and set it to zero.  Return NULL if
   267    267   ** no memory is available.  See also sqliteMallocRaw().
   268    268   */
   269    269   void *sqlite3Malloc(int n){
   270    270     void *p;
          271  +  if( n==0 ) return 0;
   271    272     if( (p = malloc(n))==0 ){
   272    273       if( n>0 ) sqlite3_malloc_failed++;
   273    274     }else{
   274    275       memset(p, 0, n);
   275    276     }
   276    277     return p;
   277    278   }