SQLite

Check-in [4622b7ce8f]
Login

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

Overview
Comment:Make sure malloc(0) always returns NULL. Fix for ticket #171. (CVS 764)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4622b7ce8f4727a6405ddf4f0af701db86da86bf
User & Date: drh 2002-10-20 15:46:23.000
Context
2002-10-20
15:53
Work around a bug in the Borland C compiler. Ticket #172. (CVS 765) (check-in: 3ef2925650 user: drh tags: trunk)
15:46
Make sure malloc(0) always returns NULL. Fix for ticket #171. (CVS 764) (check-in: 4622b7ce8f user: drh tags: trunk)
2002-10-19
20:16
Speed improvement by avoiding a call to sqliteBtreeLast() when inserting a new row into a table. (CVS 763) (check-in: d0af59fe6b 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.51 2002/09/30 01:31:22 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
#include <ctype.h>

/*
** If malloc() ever fails, this global variable gets set to 1.







|







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.52 2002/10/20 15:46:23 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
#include <ctype.h>

/*
** If malloc() ever fails, this global variable gets set to 1.
213
214
215
216
217
218
219


220
221
222
223
224
225
226
227
#if !defined(MEMORY_DEBUG)

/*
** Allocate new memory and set it to zero.  Return NULL if
** no memory is available.
*/
void *sqliteMalloc(int n){


  void *p = malloc(n);
  if( p==0 ){
    sqlite_malloc_failed++;
    return 0;
  }
  memset(p, 0, n);
  return p;
}







>
>
|







213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#if !defined(MEMORY_DEBUG)

/*
** Allocate new memory and set it to zero.  Return NULL if
** no memory is available.
*/
void *sqliteMalloc(int n){
  void *p;
  if( n==0 ) return 0;
  p = malloc(n);
  if( p==0 ){
    sqlite_malloc_failed++;
    return 0;
  }
  memset(p, 0, n);
  return p;
}