blob: 0cac07bc807b8b827f2e5d3ad7ac9bdf0e73aac4 [file] [log] [blame]
drhd1370b62008-10-28 18:58:20 +00001/*
2** 2008 October 28
3**
4** The author disclaims copyright to this source code. In place of
5** a legal notice, here is a blessing:
6**
7** May you do good and not evil.
8** May you find forgiveness for yourself and forgive others.
9** May you share freely, never taking more than you give.
10**
11*************************************************************************
12**
13** This file contains a no-op memory allocation drivers for use when
14** SQLITE_ZERO_MALLOC is defined. The allocation drivers implemented
15** here always fail. SQLite will not operate with these drivers. These
16** are merely placeholders. Real drivers must be substituted using
17** sqlite3_config() before SQLite will operate.
18**
19** $Id: mem0.c,v 1.1 2008/10/28 18:58:20 drh Exp $
20*/
21#include "sqliteInt.h"
22
23/*
24** This version of the memory allocator is the default. It is
25** used when no other memory allocator is specified using compile-time
26** macros.
27*/
28#ifdef SQLITE_ZERO_MALLOC
29
30/*
31** No-op versions of all memory allocation routines
32*/
33static void *sqlite3MemMalloc(int nByte){ return 0; }
34static void sqlite3MemFree(void *pPrior){ return; }
35static void *sqlite3MemRealloc(void *pPrior, int nByte){ return 0; }
36static int sqlite3MemSize(void *pPrior){ return 0; }
37static int sqlite3MemRoundup(int n){ return n; }
38static int sqlite3MemInit(void *NotUsed){ return SQLITE_OK; }
39static void sqlite3MemShutdown(void *NotUsed){ return; }
40
41/*
42** This routine is the only routine in this file with external linkage.
43**
44** Populate the low-level memory allocation function pointers in
45** sqlite3GlobalConfig.m with pointers to the routines in this file.
46*/
47void sqlite3MemSetDefault(void){
48 static const sqlite3_mem_methods defaultMethods = {
49 sqlite3MemMalloc,
50 sqlite3MemFree,
51 sqlite3MemRealloc,
52 sqlite3MemSize,
53 sqlite3MemRoundup,
54 sqlite3MemInit,
55 sqlite3MemShutdown,
56 0
57 };
58 sqlite3_config(SQLITE_CONFIG_MALLOC, &defaultMethods);
59}
60
61#endif /* SQLITE_ZERO_MALLOC */