mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 13:52:28 +00:00
Added sqlite-preprocessed-3350500
From https://www.sqlite.org/2021/sqlite-preprocessed-3350500.zip
This commit is contained in:
parent
4577f7fe11
commit
644f290035
157 changed files with 287529 additions and 0 deletions
87
third_party/sqlite3/fault.c
vendored
Normal file
87
third_party/sqlite3/fault.c
vendored
Normal file
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
** 2008 Jan 22
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
**
|
||||
** This file contains code to support the concept of "benign"
|
||||
** malloc failures (when the xMalloc() or xRealloc() method of the
|
||||
** sqlite3_mem_methods structure fails to allocate a block of memory
|
||||
** and returns 0).
|
||||
**
|
||||
** Most malloc failures are non-benign. After they occur, SQLite
|
||||
** abandons the current operation and returns an error code (usually
|
||||
** SQLITE_NOMEM) to the user. However, sometimes a fault is not necessarily
|
||||
** fatal. For example, if a malloc fails while resizing a hash table, this
|
||||
** is completely recoverable simply by not carrying out the resize. The
|
||||
** hash table will continue to function normally. So a malloc failure
|
||||
** during a hash table resize is a benign fault.
|
||||
*/
|
||||
|
||||
#include "sqliteInt.h"
|
||||
|
||||
#ifndef SQLITE_UNTESTABLE
|
||||
|
||||
/*
|
||||
** Global variables.
|
||||
*/
|
||||
typedef struct BenignMallocHooks BenignMallocHooks;
|
||||
static SQLITE_WSD struct BenignMallocHooks {
|
||||
void (*xBenignBegin)(void);
|
||||
void (*xBenignEnd)(void);
|
||||
} sqlite3Hooks = { 0, 0 };
|
||||
|
||||
/* The "wsdHooks" macro will resolve to the appropriate BenignMallocHooks
|
||||
** structure. If writable static data is unsupported on the target,
|
||||
** we have to locate the state vector at run-time. In the more common
|
||||
** case where writable static data is supported, wsdHooks can refer directly
|
||||
** to the "sqlite3Hooks" state vector declared above.
|
||||
*/
|
||||
#ifdef SQLITE_OMIT_WSD
|
||||
# define wsdHooksInit \
|
||||
BenignMallocHooks *x = &GLOBAL(BenignMallocHooks,sqlite3Hooks)
|
||||
# define wsdHooks x[0]
|
||||
#else
|
||||
# define wsdHooksInit
|
||||
# define wsdHooks sqlite3Hooks
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
** Register hooks to call when sqlite3BeginBenignMalloc() and
|
||||
** sqlite3EndBenignMalloc() are called, respectively.
|
||||
*/
|
||||
void sqlite3BenignMallocHooks(
|
||||
void (*xBenignBegin)(void),
|
||||
void (*xBenignEnd)(void)
|
||||
){
|
||||
wsdHooksInit;
|
||||
wsdHooks.xBenignBegin = xBenignBegin;
|
||||
wsdHooks.xBenignEnd = xBenignEnd;
|
||||
}
|
||||
|
||||
/*
|
||||
** This (sqlite3EndBenignMalloc()) is called by SQLite code to indicate that
|
||||
** subsequent malloc failures are benign. A call to sqlite3EndBenignMalloc()
|
||||
** indicates that subsequent malloc failures are non-benign.
|
||||
*/
|
||||
void sqlite3BeginBenignMalloc(void){
|
||||
wsdHooksInit;
|
||||
if( wsdHooks.xBenignBegin ){
|
||||
wsdHooks.xBenignBegin();
|
||||
}
|
||||
}
|
||||
void sqlite3EndBenignMalloc(void){
|
||||
wsdHooksInit;
|
||||
if( wsdHooks.xBenignEnd ){
|
||||
wsdHooks.xBenignEnd();
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* #ifndef SQLITE_UNTESTABLE */
|
Loading…
Add table
Add a link
Reference in a new issue