theSq3Lite 10.0 NHI1 - theKernel - theLink - theConfig - theSq3Lite - theCompiler - theBrain - theGuard - theLib - theATL
c - tcl - atl - cs - py - rb - jv - cc
Loading...
Searching...
No Matches
Sq3Lite_Internal_Alloc_C_API

Memory Allocation Subsystem … More...

+ Collaboration diagram for Sq3Lite_Internal_Alloc_C_API:

Functions

static void Sq3Free (MK_PTR N)
 Memory Allocation Subsystem …
 
static MK_PTR Sq3Malloc (MK_I32 N)
 Memory Allocation Subsystem …
 
static MK_PTR Sq3Malloc64 (MK_I64 N)
 Memory Allocation Subsystem …
 
static MK_I64 Sq3Msize (MK_PTR N)
 Memory Allocation Subsystem …
 
static MK_PTR Sq3Realloc (MK_PTR arg0, MK_I32 N)
 Memory Allocation Subsystem …
 
static MK_PTR Sq3Realloc64 (MK_PTR arg0, MK_I64 N)
 Memory Allocation Subsystem …
 

Sq3Lite - Sq3Lite_Internal_Alloc_C_API - function

void Sq3FreeP (MK_PTR N)
 Non-inline replacement for Sq3Free
 
MK_PTR Sq3MallocP (MK_I32 N)
 Non-inline replacement for Sq3Malloc
 
MK_PTR Sq3Malloc64P (MK_I64 N)
 Non-inline replacement for Sq3Malloc64
 
MK_I64 Sq3MsizeP (MK_PTR N)
 Non-inline replacement for Sq3Msize
 
MK_PTR Sq3ReallocP (MK_PTR arg0, MK_I32 N)
 Non-inline replacement for Sq3Realloc
 
MK_PTR Sq3Realloc64P (MK_PTR arg0, MK_I64 N)
 Non-inline replacement for Sq3Realloc64
 

Detailed Description

Memory Allocation Subsystem …

The SQLite core uses these three routines for all of its own internal memory allocation needs. "Core" in the previous sentence does not include operating-system specific VFS implementation. The Windows VFS uses native malloc() and free() for some operations.

The Sq3Malloc() routine returns a pointer to a block of memory at least N bytes in length, where N is the parameter. If Sq3Malloc() is unable to obtain sufficient free memory, it returns a NULL pointer. If the parameter N to Sq3Malloc() is zero or negative then Sq3Malloc() returns a NULL pointer.

The Sq3Malloc64(N) routine works just like Sq3Malloc(N) except that N is an unsigned 64-bit integer instead of a signed 32-bit integer.

Calling Sq3Free() with a pointer previously returned by Sq3Malloc() or Sq3Realloc() releases that memory so that it might be reused. The Sq3Free() routine is a no-op if is called with a NULL pointer. Passing a NULL pointer to Sq3Free() is harmless. After being freed, memory should neither be read nor written. Even reading previously freed memory might result in a segmentation fault or other severe error. Memory corruption, a segmentation fault, or other severe error might result if Sq3Free() is called with a non-NULL pointer that was not obtained from Sq3Malloc() or Sq3Realloc().

The Sq3Realloc(X,N) interface attempts to resize a prior memory allocation X to be at least N bytes. If the X parameter to Sq3Realloc(X,N) is a NULL pointer then its behavior is identical to calling Sq3Malloc(N). If the N parameter to Sq3Realloc(X,N) is zero or negative then the behavior is exactly the same as calling Sq3Free(X). Sq3Realloc(X,N) returns a pointer to a memory allocation of at least N bytes in size or NULL if insufficient memory is available. If M is the size of the prior allocation, then min(N,M) bytes of the prior allocation are copied into the beginning of buffer returned by Sq3Realloc(X,N) and the prior allocation is freed. If Sq3Realloc(X,N) returns NULL and N is positive, then the prior allocation is not freed.

The Sq3Realloc64(X,N) interfaces works the same as Sq3Realloc(X,N) except that N is a 64-bit unsigned integer instead of a 32-bit signed integer.

If X is a memory allocation previously obtained from Sq3Malloc(), Sq3Malloc64(), Sq3Realloc(), or Sq3Realloc64(), then Sq3Msize(X) returns the size of that memory allocation in bytes. The value returned by Sq3Msize(X) might be larger than the number of bytes requested when X was allocated. If X is a NULL pointer then Sq3Msize(X) returns zero. If X points to something that is not the beginning of memory allocation, or if it points to a formerly valid memory allocation that has now been freed, then the behavior of Sq3Msize(X) is undefined and possibly harmful.

The memory returned by Sq3Malloc(), Sq3Realloc(), Sq3Malloc64(), and Sq3Realloc64() is always aligned to at least an 8 byte boundary, or to a 4 byte boundary if the SQLITE_4_BYTE_ALIGNED_MALLOC compile-time option is used.

The pointer arguments to Sq3Free () and Sq3Realloc () must be either NULL or else pointers obtained from a prior invocation of Sq3Malloc () or Sq3Realloc () that have not yet been released.

The application must not read or write any part of a block of memory after it has been released using Sq3Free () or Sq3Realloc ().

Reference code from sqlite3:

SQLITE_API void *sqlite3_realloc(void*, int);
SQLITE_API void * sqlite3_malloc64(sqlite3_uint64)
#define SQLITE_API
sqlite_uint64 sqlite3_uint64
SQLITE_API void * sqlite3_realloc64(void *, sqlite3_uint64)
SQLITE_API sqlite3_uint64 sqlite3_msize(void *)
SQLITE_API void sqlite3_free(void *)
SQLITE_API void * sqlite3_realloc(void *, int)
SQLITE_API void * sqlite3_malloc(int)

Function Documentation

◆ Sq3Free()

static void Sq3Free ( MK_PTR N)
inlinestatic

Memory Allocation Subsystem …

read more at 'Sq3Lite_Internal_Alloc_C_API'

Definition at line 765 of file LibSq3Lite_sq3.h.

765 {
766 sqlite3_free((MK_PTR)(N));
767 }
MK_PTRB * MK_PTR

◆ Sq3FreeP()

void Sq3FreeP ( MK_PTR N)

Non-inline replacement for Sq3Free

◆ Sq3Malloc()

static MK_PTR Sq3Malloc ( MK_I32 N)
inlinestatic

Memory Allocation Subsystem …

read more at 'Sq3Lite_Internal_Alloc_C_API'

Definition at line 770 of file LibSq3Lite_sq3.h.

770 {
771 return (MK_PTR)sqlite3_malloc(N);
772 }

◆ Sq3Malloc64()

static MK_PTR Sq3Malloc64 ( MK_I64 N)
inlinestatic

Memory Allocation Subsystem …

read more at 'Sq3Lite_Internal_Alloc_C_API'

Definition at line 775 of file LibSq3Lite_sq3.h.

775 {
776 return (MK_PTR)sqlite3_malloc64((MK_U64)N);
777 }
unsigned long long MK_U64

◆ Sq3Malloc64P()

MK_PTR Sq3Malloc64P ( MK_I64 N)

Non-inline replacement for Sq3Malloc64

◆ Sq3MallocP()

MK_PTR Sq3MallocP ( MK_I32 N)

Non-inline replacement for Sq3Malloc

◆ Sq3Msize()

static MK_I64 Sq3Msize ( MK_PTR N)
inlinestatic

Memory Allocation Subsystem …

read more at 'Sq3Lite_Internal_Alloc_C_API'

Definition at line 780 of file LibSq3Lite_sq3.h.

780 {
781 return (MK_I64)sqlite3_msize((MK_PTR)(N));
782 }
signed long long MK_I64

◆ Sq3MsizeP()

MK_I64 Sq3MsizeP ( MK_PTR N)

Non-inline replacement for Sq3Msize

◆ Sq3Realloc()

static MK_PTR Sq3Realloc ( MK_PTR arg0,
MK_I32 N )
inlinestatic

Memory Allocation Subsystem …

read more at 'Sq3Lite_Internal_Alloc_C_API'

Definition at line 785 of file LibSq3Lite_sq3.h.

785 {
786 return (MK_PTR)sqlite3_realloc((MK_PTR)(arg0), N);
787 }

◆ Sq3Realloc64()

static MK_PTR Sq3Realloc64 ( MK_PTR arg0,
MK_I64 N )
inlinestatic

Memory Allocation Subsystem …

read more at 'Sq3Lite_Internal_Alloc_C_API'

Definition at line 790 of file LibSq3Lite_sq3.h.

790 {
791 return (MK_PTR)sqlite3_realloc64((MK_PTR)(arg0), (MK_U64)N);
792 }

◆ Sq3Realloc64P()

MK_PTR Sq3Realloc64P ( MK_PTR arg0,
MK_I64 N )

Non-inline replacement for Sq3Realloc64

◆ Sq3ReallocP()

MK_PTR Sq3ReallocP ( MK_PTR arg0,
MK_I32 N )

Non-inline replacement for Sq3Realloc