SQLite

Check-in [657d74ebc1]
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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 657d74ebc1d91c99e8ac6cd68fdac3864ebd8d71
User & Date: drh 2005-06-29 15:33:00.000
Context
2005-06-29
17:24
Check for zero-byte allocations in sqlite3MallocRaw. (CVS 2533) (check-in: 78cb8a9a17 user: drh tags: trunk)
15:33
Make sqlite3Malloc always return NULL when the number of bytes to allocate is 0. (CVS 2532) (check-in: 657d74ebc1 user: drh tags: trunk)
2005-06-26
20:00
Update SQL syntax documentation to describe the new CAST expressions. (CVS 2531) (check-in: d5392866bf user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/util.c.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
**
*************************************************************************
** Utility functions used throughout sqlite.
**
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.138 2005/06/25 18:42:15 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
#include <ctype.h>

#if SQLITE_MEMDEBUG>2 && defined(__GLIBC__)
#include <execinfo.h>







|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
**
*************************************************************************
** Utility functions used throughout sqlite.
**
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.139 2005/06/29 15:33:00 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
#include <ctype.h>

#if SQLITE_MEMDEBUG>2 && defined(__GLIBC__)
#include <execinfo.h>
264
265
266
267
268
269
270

271
272
273
274
275
276
277

/*
** Allocate new memory and set it to zero.  Return NULL if
** no memory is available.  See also sqliteMallocRaw().
*/
void *sqlite3Malloc(int n){
  void *p;

  if( (p = malloc(n))==0 ){
    if( n>0 ) sqlite3_malloc_failed++;
  }else{
    memset(p, 0, n);
  }
  return p;
}







>







264
265
266
267
268
269
270
271
272
273
274
275
276
277
278

/*
** Allocate new memory and set it to zero.  Return NULL if
** no memory is available.  See also sqliteMallocRaw().
*/
void *sqlite3Malloc(int n){
  void *p;
  if( n==0 ) return 0;
  if( (p = malloc(n))==0 ){
    if( n>0 ) sqlite3_malloc_failed++;
  }else{
    memset(p, 0, n);
  }
  return p;
}