/ Check-in [006fd69b]
Login

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

Overview
Comment:Handle a real system malloc() failure in mem1.c. (CVS 5281)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 006fd69bf56f05448fd9aa82d3b1cdcc175369ad
User & Date: danielk1977 2008-06-23 15:10:25
Context
2008-06-23
15:55
Run (a subset of) the rtree tests from quick.test. (CVS 5282) check-in: e872c78c user: danielk1977 tags: trunk
15:10
Handle a real system malloc() failure in mem1.c. (CVS 5281) check-in: 006fd69b user: danielk1977 tags: trunk
14:40
Remove a non-ansi construct from mem1.c - an assert() statement before the variable declarations in a function. (CVS 5280) check-in: 1de98da6 user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/mem1.c.

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
..
37
38
39
40
41
42
43

44


45
46
47
48
49
50
51
52
** This file contains low-level memory allocation drivers for when
** SQLite will use the standard C-library malloc/realloc/free interface
** to obtain the memory it needs.
**
** This file contains implementations of the low-level memory allocation
** routines specified in the sqlite3_mem_methods object.
**
** $Id: mem1.c,v 1.22 2008/06/23 14:40:18 danielk1977 Exp $
*/
#include "sqliteInt.h"

/*
** This version of the memory allocator is the default.  It is
** used when no other memory allocator is specified using compile-time
** macros.
................................................................................
** routines.
*/
static void *sqlite3MemMalloc(int nByte){
  sqlite3_int64 *p;
  assert( nByte>0 );
  nByte = (nByte+7)&~7;
  p = malloc( nByte+8 );

  p[0] = nByte;


  return (void*)&p[1];
}

/*
** Like free() but works for allocations obtained from sqlite3MemMalloc()
** or sqlite3MemRealloc().
**
** For this low-level routine, we already know that pPrior!=0 since







|







 







>
|
>
>
|







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
..
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
** This file contains low-level memory allocation drivers for when
** SQLite will use the standard C-library malloc/realloc/free interface
** to obtain the memory it needs.
**
** This file contains implementations of the low-level memory allocation
** routines specified in the sqlite3_mem_methods object.
**
** $Id: mem1.c,v 1.23 2008/06/23 15:10:25 danielk1977 Exp $
*/
#include "sqliteInt.h"

/*
** This version of the memory allocator is the default.  It is
** used when no other memory allocator is specified using compile-time
** macros.
................................................................................
** routines.
*/
static void *sqlite3MemMalloc(int nByte){
  sqlite3_int64 *p;
  assert( nByte>0 );
  nByte = (nByte+7)&~7;
  p = malloc( nByte+8 );
  if( p ){
    p[0] = nByte;
    p++;
  }
  return (void *)p;
}

/*
** Like free() but works for allocations obtained from sqlite3MemMalloc()
** or sqlite3MemRealloc().
**
** For this low-level routine, we already know that pPrior!=0 since